1) In order to copy an object, use this code:
string s;
string t = s;
1a) What do those pointers represent? If they represent exclusive ownership, you must copy the objects they point to when copying the owning object. Check any good text's introduction to constructors and destructors. Consider making the LivingObject
class non-copyable.
2) Try this:
shared_ptr<T> p(new T);
vector<T> v;
v.push_back(p);
...
shared_ptr<T> q = v[0];
q->member_function();
As a last advise, you need a good C++ book. Another great resource is an online community of other users like this one here. If possible, try to reduce your code though. It's enough that LivingObject
has one example pointer. Good luck!