You send a message to an object.
When you say c = a+b; you are sending the `assign' (operator=) message to the `c' object
The body of the message is `a+b', that it is sending the message `sum' (operator+) to the object `a'
You wrote Person Person::operator+(const Person& A,const Person& B)
that would be used as useless.operator+(a,b);
¿now why do you want the `useless' object? (hint: you don't, it's useless)
Instead you want to use it like a.operator+(b); or for short a + b;
The you would write
1 2 3 4 5 6 7 8
Person Person::operator+(const Person& B) const{ //as a non-static member function
return Person(this->fname, b.lname, 0);
}
//or
Person operator+(const Person& A,const Person& B){ //as a non-member function
return Person(A.fname , B.lname, 0);
}
However, that's not an intuitive way to add people.
The zero parameter refers to when you use it as a sign
like