V
Vincent RICHOMME
Hi,
Let' say I have a class with an object pointer as member something like:
// classA.h
class A
{
A(B* pB);
B* m_pB;
};
//classA.cpp
class A:A(B* pB):
m_pB(NULL)
{
m_pB = pB;
if (m_pB == NULL)
return;
}
so I want to be sure m_pB is not NULL, so I am initializing it in
initialization list with NULL and after I am checking its value.
But my question is what is done first, the initialization(m_pB=NULL) or
the declaration in the body ?
Let' say I have a class with an object pointer as member something like:
// classA.h
class A
{
A(B* pB);
B* m_pB;
};
//classA.cpp
class A:A(B* pB):
m_pB(NULL)
{
m_pB = pB;
if (m_pB == NULL)
return;
}
so I want to be sure m_pB is not NULL, so I am initializing it in
initialization list with NULL and after I am checking its value.
But my question is what is done first, the initialization(m_pB=NULL) or
the declaration in the body ?