[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.
Implicit type conversions usually lead to more harm than good, so don’t provide conversion functions unless we’re sure we want them.
Including meaningless default constructors affects the efficiency of classes, so avoiding them in classes guarantees fully-initialized objects, with the cost of some limits on how such classes can be used.
More effective C++: Use references when we already have something to refer to and never want to refer to anything else, or when implementing operators whose syntactic requires us to do so.
When we write a placement version of operator new
, be sure to write the corresponding placement version of operator delete
to avoid subtle, intermittent memory leaks. When we do so, pay attention not to unintentionally hide the normal versions of new
and delete