Home > Back-end >  The overloaded operators in the class
The overloaded operators in the class

Time:10-05

Vector& Vector: : operator=(Vector& C)
{
For (int I=0; i V [I] [I]=C;
Return * this;
}

Why "=" complains?

CodePudding user response:

You only overloading=no reloading the + and -
A + B results break what type

CodePudding user response:

Accept temporary variables must add const, const reference, their writing classes must be want to consider this,
Vector& Vector: : operator=( const Vector& C)

C + + 11 after the right value concept, consider a move semantics, then define a best
Vector& Vector: : operator=(Vector & amp; & C)
  • Related