Rule-of-Three becomes Rule-of-Five with C++11? [closed]

I’d say the Rule of Three becomes the Rule of Three, Four and Five: Each class should explicitly define exactly one of the following set of special member functions: None Destructor, copy constructor, copy assignment operator In addition, each class that explicitly defines a destructor may explicitly define a move constructor and/or a move assignment … Read more

What is The Rule of Three?

Introduction C++ treats variables of user-defined types with value semantics. This means that objects are implicitly copied in various contexts, and we should understand what “copying an object” actually means. Let us consider a simple example: class person { std::string name; int age; public: person(const std::string& name, int age) : name(name), age(age) { } }; … Read more