Home > Back-end >  The vector subclass assigned to the vector parent class
The vector subclass assigned to the vector parent class

Time:09-23

Father is Son of the parent
For example:
Father a;
Son of b;
A=b;
The problem is that there is no
But:
Vector a;
Vector b;
A=b;//will go wrong
Excuse me, how to subclass vector assigned to the parent class

CodePudding user response:

Vector a;
Vector b;
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 & Operator=(vector & B);

CodePudding user response:

Elder brother,=is not everything

CodePudding user response:

 
Vector a;
Vector b;
A.a ssign (b.b do v.begin (), v.end ());
  • Related