Archived

This topic is now archived and is closed to further replies.

Overloading operators in C++

This topic is 5009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

All operators, with the exception of the dot operator, the dot-star operator, the scope resolution operator, the ternary operator, and the sizeof operator (yes, sizeof is technically an operator).


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
you can overload any operator.

you forgot, among others:

<<, >>, ++, --, +=, -=, *=, /=, probably more. why not just google the web and read a chapter on operator overloading?

-me

Share this post


Link to post
Share on other sites
MSDN List of Overloadable Operators

Especially powerful ones could include (), [], new, and delete. Heck, you can even confuse everyone who looks at your code by overloading the comma operator and using it all the time. Not recommended, of course, but doable.


int Agony() { return *((int*)0); }    Mwahaha... >8)

Share this post


Link to post
Share on other sites