The difference lies in what signature you choose for your overload(s) of Cited from the relevant article on this subject in the C++ FAQ (go there for more details):
|
Object non-member function:
This is another way to do this: As long as the functions are in the same namespace as the object they are referring too, they will be considered when the compiler will search for a fonction to handle ++t
;
or t++
;
code:
class T
{
// etc.
} ;
T & operator++(T & p_oRight) // ++A
{
// Do increment of p_oRight value
return p_oRight ;
}
T operator++(T & p_oRight, int) // A++
{
T oCopy ;
// Copy p_oRight into oCopy
// Do increment of p_oRight value
return oCopy ;
}
The difference lies in what signature you choose for your overload(s) of Cited from the relevant article on this subject in the C++ FAQ (go there for more details):
|