   boost::shared_ptr - A "For the sake of simplicity" issue
  Hey,boost::shared_ptr obj1(new cobj1);boost::shared_ptr obj2(new cobj2);obj1->set_obj2(obj2);obj2->set_obj1(obj1);being: set_obj[x](boost::shared_ptr obj).The question is: Is there any trick I can use to set the shared_ptr inside obj1 from within object2 so I can just do:obj2->set_obj1(obj1); // set_obj1 will call obj1->set_obj2([somehow I can has a shared_ptr=this]tnx   
  You probably already know this, but just in case :)You're constructing a cyclic reference in your example: obj1 will keep obj2 alive and obj2 will keep obj1 alive. In other words, unless you break the reference somehow, both objects will not be freed.There's a weak_ptr class that can be used to obtain a shared_ptr to the object at any time but doesn't increase its reference counter to keep it alive (if you try to obtain a shared_ptr from the weak_ptr but the object has already been destroyed, it returns an empty shared_ptr).-Back to the original questionTo be able to obtain a shared_ptr inside the object, you can derive from enable_shared_from_this.You could then write:class obj2 {  public: void set_obj1(const shared_ptr<obj1> &obj1) {    this->obj1 = obj1;    obj1->set_obj2(shared_from_this());  }};;  Perfect. Thank you very much!   