Suppose I have a class:
class State {
std::shared_ptr<Graph> _graph;
public:
State():_graph(new Graph){}
};
With regards to rule of three, apparently no need to free _graph in destructor as it is a smart pointer. The question is, do I need to write copy constructor and assignment operator for it?
Considering following:
State s1;
State s2 = s1;
What will happen with the second line?
Looks like it will be s2._graph = s1._graph;
, pointer shared, so we are safe?