Hi guys
Please take a look at this example:
Please note that when using the overloaded operator for an instance of X, we can call it usingCode:class X { public: // member prefix ++x void operator++() { } }; class Y { }; // non-member prefix ++y void operator++(Y&) { } int main() { X x; Y y; // calls x.operator++() ++x; // explicit call, like ++x x.operator++(); // calls operator++(y) ++y; // explicit call, like ++y operator++(y); }
In the case with the overloaded operator ++ for an instance of Y (it is overloaded using a non-member function), we can call it usingCode:x.operator++()
My question is: Is there any reasoning behind the fact that we cannot call the two operators using the same syntax? Or is that just the way it is?Code:operator++(y)
Best,
Niles.



LinkBack URL
About LinkBacks




