Привет форумчане.
Вроде знаю что объекты должны располагаться один за одним, но вижу иное, с гапом.
#include <iostream>
class Mom {
public:
int s = 0;
};
class Dad {
public:
int s = 1;
};
class Grand {
public:
int s = 5;
};
class Son : public Mom, Dad, Grand{
public:
int s = 2;
};
int main()
{
Mom mom;
Dad dad;
Grand grand;
Son son;
std::cout << "Hello World!\n Mom s = "<<mom.s << " Dad = " << dad.s << " Son = " << son.s;
std::cout << "\n";
std::cout << "Mom = " << sizeof(mom) << "\n";
std::cout << "Dad = " << sizeof(dad) << "\n";
std::cout << "Grand = " << sizeof(grand) << "\n";
std::cout << "Son = " << sizeof(son) << "\n";
std::cout << "Mom = " << &mom << "\n";
std::cout << "Dad = " << &dad << "\n";// << (&dad) - (&mom);
std::cout << "Grand = " << &grand << "\n";
std::cout << "Son = " << &son << "\n";
}