Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Mar 2, 1998

Operator overloading rules of thumb

When overloading an operator to support a user-defined type (object), it is best to adhere to the basic semantics of that built-in operator. For instance, the built-in operator ==, which does not modify any of its operands, should also be overloaded in such a way that it does not modify any of its operands (and should be declared as a const member function, as a matter of fact). On the other hand, operators such as + =, which do modify their left operand, should be overloaded in a way that reflects that, i.e., by changing their objects. Note that in many cases, the implementer
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap