boostshared-ptr

boost shared_ptr and 'this'

I have two classes with a parent-child relationship (customer&order directory&file etc) I have typedef boost::shared_ptr<Parent> ParentPtr and in parent class a method to make a child I need child instances to have pointers to their parent. class Child { .... ParentPtr m_parent; .... } I want it to be a shared_ptr so that...

question on assignment with boost::shared_ptr (vs. the reset() function)

Sorry if this is explicitly answered somewhere, but I'm a little confused by the boost documentation and articles I've read online. I see that I can use the reset() function to release the memory within a shared_ptr (assuming the reference count goes to zero), e.g., shared_ptr<int> x(new int(0)); x.reset(new int(1)); This, I believe ...

return boost::shared_ptr question, why destructor got called 3 times

class Obj_A { public: ~Ojb_A() { cout << "calling Obj_A() destructor\n"; } void method1() { cout << "invoking Obj_A::method1()\n"; } }; class Obj_B { boost::shared_ptr<Obj_A> _objA; public: Obj_B(Obj_A *objA) { _objA.reset(objA) } void method1() { _objA->method1(); } }; class...