Under what circumstances must I provide, assignment operator, copy constructor and destructor for my C++ class?
assignment-operator, c++, copy-constructor, destructor
Solution
In case your class contains only vector/string objects as its data members, you don't need to implement these. The C++ STL classes (like vector, string) have their own copy ctor, overloaded assignment operator and destructor.
But in case if your class allocates memory dynamically in the constructor then a naive shallow copy will lead to trouble. In that case you'll have to implement copy ctor, overloaded assignment operator and destructor.
Problem
Say I've got a class where the sole data member is something like `std::string` or `std::vector`. Do I need to provide a Copy Constructor, Destructor and Assignment Operator?