shared_ptr as class member

Posted by idimba on Stack Overflow See other posts from Stack Overflow or by idimba
Published on 2010-05-10T05:31:38Z Indexed on 2010/05/10 8:54 UTC
Read the original article Hit count: 207

Filed under:
|
|

It's common to declared contained objects as a pointers to that class, while "forward declarating" them in header file. This in order to reduce physical dependencies in code.

For example

class B;  // forward declaration   

class A {
   private:
      B* pB;
};

Would it be good idea to declare such a member as shared_ptr, instead of naked pointer? I would prefer scoped_ptr, but AFAIKit it won't be in standard.

© Stack Overflow or respective owner

Related posts about boost

Related posts about shared-ptr