Overloading the -> operator...

Started by
10 comments, last by PlayGGY 20 years, 4 months ago
i was always told by my comp sci profs that it's a bad thing to overload the -> operator because it gets really messy and it usually thought of as "bad" style along with the & operator and a few others so you should avoid them if possible

[edited by - Hexxagonal on December 13, 2003 1:58:23 PM]
Advertisement
quote:Original post by Hexxagonal
i was always told by my comp sci profs that it''s a bad thing to overload the -> operator because it gets really messy and it usually thought of as "bad" style along with the & operator and a few others so you should avoid them if possible

Personally I strongly disagree; operator overloading should always be done responsibly (giving operators unexpected semantics is terribly confusing and worse by far than having to type out function calls), but used properly, they can make things much clearer. In the case of operator->, it makes perfect sense (as has been pointed out) to overload it when designing smart pointer classes, for instance, allowing smart pointers to be used in the same fashion as built-in ones.

This topic is closed to new replies.

Advertisement