[MECpp]Item-8 Understand the Different Meanings of New and Delete
· โ 4 min read
[MECpp]Item-7 Never Overload '&&', '||', or ','
· โ 3 min read
If we don’t have a good reason for overloading an operator, don’t overload it. In the case of &&
, ||
, and ,
, it’s difficult to have a good reason: we can’t make them behave the way they’re supposed to.
[MECpp]Item-6 Distinguish Between Prefix and Postfix Forms of Increment and Decrement Operators
· โ 3 min read
The prefix and postfix forms of increment and decrement operators return different types: prefix forms return a reference, while postfix forms return a const object. For efficiency, prefer prefix forms unless the behavior of postfix ones is necessary. To guarantee consistency, implement postfix operators in terms of the prefix operators.
[MECpp]Item-5 Be Wary of User Defined Conversion Functions
· โ 4 min read
Implicit type conversions usually lead to more harm than good, so don’t provide conversion functions unless we’re sure we want them.