posted 23 years ago
Hello Everyone,
I have some doubts regarding the following issue:
If class B extends class A, does a class A object get created when we instantiate a class B object?
Does the object get created when the constructor is called or is it created only when �new� is used?
Bruce Eckel writes:
�When you create an object of the derived class, it contains within it a subobject of the base class. This subobject is the same as if you had created an object of the base class by itself. It�s just that, from the outside, the subobject of the base class is wrapped within the derived-class object.�
Does it mean that when we instantiate the object of the derived class, we end up with both an instance of a derived class and instance of the base class?
I�d appreciate if someone could explain this to me, please.
TIA
A.