146. Inheritance

Question.4

A derived object is assigned to a base variable by value:

class Base { public: int x = 1; };
class Derived : public Base {
public: int y = 2; };

Derived d;
Base b = d;  // Copy by value
printf("%zu", sizeof(b));

Does b contain the y member?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!