For example:
Father a;
Son of b;
A=b;
The problem is that there is no
But:
Vector
Vector
A=b;//will go wrong
Excuse me, how to subclass vector assigned to the parent class
CodePudding user response:
VectorVector
A=b;//will go wrong
Excuse me, how to subclass vector assignment to the parent class
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Here a and b are the same as for the vector class, there is no inheritance relationships, and the vector as a generic container class, cannot achieve a=b, or a management point to the Father of the block of memory is messed up,
You can only according to your list of overloaded operator=implementation, such as vector
CodePudding user response:
Elder brother,=is not everythingCodePudding user response:
Vectora;
Vectorb;
A.a ssign (b.b do v.begin (), v.end ());