|
-
April 30th, 2009, 10:27 AM
#8
Re: Operator Overloading, in General
 Originally Posted by laserlight
hmm... but isn't it wrong to make the function const?
Sorry, got that wrong. I meant const return.
So, what you might need to remember is to consider whether you should define operator+ in terms of operator+= and whether it should return by value or by reference... but the latter should become obvious when you are actually trying to implement it, right?
Your memory is obviously better than mine. When I get to that point I'm thinking "Return by value or reference. Const?" The problem is if you remember it incorrectly then everything may appear to work... for a while. I'm sure the rules will stick eventually, but for now I'm keeping my crib sheet.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|