Rule of Zero — don't define any of the special functions. Use smart pointers and containers.
1#include <memory>2#include <vector>34class MyClass {5private:6 std::unique_ptr<int> data;7 std::vector<int> items;89public:10 MyClass(int value) : data(std::make_unique<int>(value)) {}11 // No destructor, copy, or move needed!12 // All auto-generated correctly.13};
Advantages:
Best practice:
std::unique_ptr, std::shared_ptr.