Archived

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

fatherjohn666

some issues

Recommended Posts

When reading a tutorial I come across operators etc. Is there a dsicernable difference between say const CVector& operator== and const CVector &operator== surely the ampersand has a different meaning depending on what is hooks onto? can someone clear this up for us? cheers. I would have thought the ampersand would sit next to operator, but the tutorials I follow have them varied sometimes??? is this a misprint or.... the more common one in the tuts I follow is my first example cheers Im just a beginner!!! http://www.actsofgord.com

Share this post


Link to post
Share on other sites
It''s both the same.

But the spelling

const CVector& operator ==

should be considered the better one.
The & operator marks a reference. In this case, the operator ==
returns a constant reference to a CVector object. It would not
make sense to bind the & more to the operator keyword as it
really belongs to the return value (CVector).

Share this post


Link to post
Share on other sites