1 Oct
2009
1 Oct
'09
2:36 p.m.
Hi, I've a doubt about shared_ptr... Suppose to have something like this: template class Interface {..pure virtual..} template class Impl1 : public Interface {....} template class Impl2 : public Interface {....} class A { public: Interface* GetObjPtr() { return &obj; } private: Impl2 obj; }; class B { ~B() { delete a_ptr; } B() { a_ptr = new A; Int_ptr.reset( a_ptr->GetObjPtr ); } private: A* a_ptr; shared_ptr< Interface > Int_ptr; }; Where B creates and use A on its internal. In this case, is 'delete' called twice for Impl2? (When A is destroyed and when B, and its shared_ptr, is destroyed). Thanks, Daniele.