I have written a class on C ++ in my class and I override the plus operator.
This prototype is:
WAR operator + (CONSTORE and var);Why does the IDE tell me that this is correct:
one = 3; A + 5; // True
But is not it?
one = 3; 5 + A; // error
Do I have to add an object with this object to my object?
The reason for this is that operators are not symmetric as member functions, the operator you define , The purpose of that class should always be on the left side.
What do you want - you should work as an operator outside the classroom.
Var operator (Constable and Constant War amp);
And if you need to reach the private areas, then declare it as a friend festival.
No comments:
Post a Comment