An owned pointer has to be initialized (1) and validated (2) bofore its usage (3) :)
class B
{
public:
void f();
};
class A
{
B* m_pcB;
public:
A() : m_pcB(NULL ) {}
void UseB() { if (m_pcB ) m_pcB->f(); }
void ResetB() { if (m_pcB ) { delete m_pcB ; m_pcB = NULL } }
}
All (owned and not owned) pointers should be validated before their usage.