|
Operators that are members have one less parameter in the form of declaration and definition than operators that are not members. This is because c++
The first parameter this is hidden from all member functions
Similarly, the overloaded operator as a member function is also one more than the function parameter as a friend. Take the operator +, for example, in the member function, its first parameter is the object it belongs to, the second Is a parameter, and in the friend function, both objects are parameters
The statement is as follows
Member function version: SomeClass operator + (SomeClass)
Friends function version: friend SomeClass operator + (SomeClass, SomeClass)
Someclass is a class name, assuming that both functions return SomeClass objects. |
|