class B;
class A
{
public:
A ()
: m_b(new B())
{
}
shared_ptr GimmeB ()
{
return m_b;
}
private:
shared_ptr&l
Generally, I would avoid using raw pointers as far as possible since they have very ambiguous meaning - you might have to deallocate the pointee, but maybe not, and only human-read and -written documentation tells you what the case is. And documentation is always bad, outdated or misunderstood.
If ownership is an issue, use a smart pointer. If not, I'd use a reference if practicable.