Reputation: 744
I have following scenario:
I have an Abstract base class with no copy constructor no assignment operator has some data members
a derived class (derived from above base class) has assignment operator has some data members
How the members of base class will be copied when we copy a derived class object to another existing derived class object. I understand as we have an assignment operator defined for derived class which copies derived class members but how base class members will be copied, will it be through default assignment operator?
Upvotes: 1
Views: 276
Reputation: 27577
How the members of base class will be copied
Since there's no explicit copy constructor, one will be generated by the compiler. It will in turn call/generate copy constructors for the data members of the base class. At the end, builtin types (int
, float
, pointers! etc are simply copied), types with copy constructors can copy themselves, any other type will generate a compile time error.
Upvotes: 3