Overloading the shorthand addition operator (+=) in c++:
Note, this is operator overloading the += operator for a STRUCT.
called "deathNote". I follow the constant-class rule for classes.
But use lowercase for structs because structs are value-types / primitives.
So they should be treated like "int", "float", "char", "string", etc.
Which all start with lowercase letters.
deathNote operator_-(const deathNote &a){
this->apples = a.apples + this->apples;
this->chocolate = a.chocolate + this->chocolate;
this->paper = a.paper + this->paper;
return (*this);
}
No comments:
Post a Comment