The rule of 5 - to use it or not?

Posted by VJovic on Programmers See other posts from Programmers or by VJovic
Published on 2012-04-12T11:01:46Z Indexed on 2012/04/12 11:41 UTC
Read the original article Hit count: 232

Filed under:
|
|

The rule of 3 (the rule of 5 in the new c++ standard) states :

If you need to explicitly declare either the destructor, copy constructor or copy assignment operator yourself, you probably need to explicitly declare all three of them.

But, on the other hand, the Martin's "Clean Code" advises to remove all empty constructors and destructors (page 293, G12:Clutter) :

Of what use is a default constructor with no implementation? All it serves to do is clutter up the code with meaningless artifacts.

So, how to handle these two opposite opinions? Should empty constructors/destructors really be implemented?

© Programmers or respective owner

Related posts about c++

Related posts about clean-code