Skip to main content
gamedev.net
🔒 Locked

Cant overload operator. ?

Started by The C modest god 3 replies 550+ views
Original Post
The C modest god
The C modest god
Is there no way to overload operator.? It makes a bit since, because overloading it will not allow to access class methods directly?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Adam Hamilton
Adam Hamilton
I am not sure what your trying to say. You can't overload the ?: operator if that is maybe what you mean.

What do you mean not allow access class methods directly?

Post an example what you want to do.
deathkrush
deathkrush
Overloading the . operator would be equivalent to "#define public private" so it's not allowed in C++. You can overload the -> operator though.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
mrdaveo
mrdaveo
Here is the list for allowed operators :)

http://msdn2.microsoft.com/en-us/library/ha4ct2b0.aspx


Maybe that will help you :)
Zahlman
Zahlman
You can't overload '.' (because you'd lose access to the normal way of selecting data or member functions; and imagine the weird things that would necessarily happen if you tried to use "foo.operator.(bar)" explicitly), '?:' ("the ternary operator", because it's the only ternary operator and Stroustrup didn't see a point in adding special support for that - what would you do with it anyway?) or '::' (scope resolution, which is special in other ways too, operator-wise). Everything else is fair game (unfortunately). :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.