Comparing objects using bool operator==

Viewed 7071

So, after reading some SO questions and answers, i still doesn't understand why use

friend bool operator==( BaseClass const &left, BaseClass const &right )

instead of

bool operator==( BaseClass const &right )

right now I have something like this http://pastebin.com/pKsTabC0 (Fixed) - and it seems to work fine. But maybe I'm missing something? Any Suggestions?

Update 1

Ok i changed the source to make it work right http://ideone.com/fIAmB. Removed unnecessary virtual and added const. Still i dont understand why to use friends...

4 Answers
Related