How to make all copies of a shared_ptr equal to another shared_ptr?
问题 I cannot figure this out.. Looks like I'm missing something simple? What do I put in MakePointToSameValue so that at point (1) both b.ptr and c.ptr point to the same as a.ptr in other words, a.ptr.get() == b.ptr.get() == c.ptr.get() the value originally pointed to by b.ptr and c.ptr gets deleted ? struct Test { public: Test( int val ) : ptr( std::make_shared< int >( val ) ) { } void MakePointToSameValue( Test& other ) { //what do I put here? //other.ptr = this->ptr; //doesn't do it } private: