I am curious about something dealing with constructors in dialog classes. I have seen a certain way of doing the constructor and I wonder if it actually buys anything. Here is what I am talking about:
FOO::FOO(CWnd* pParent /*=NULL*/)
: CDialog(FOO::IDD, pParent),
m_pSomeObject( NULL ),
m_bSomeBoolean( false ),
m_iSomeInt( 0 ),
m_sSomeString( "" )
{
//{{AFX_DATA_INIT(FOO)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
Now m_pSomeObject, m_bSomeBoolean, m_iSomeInt, and m_sSomeString are member variables of the class. So, they are being initialized. Is this method of defining a constructor better than doing it this way?
FOO::FOO(CWnd* pParent /*=NULL*/)
: CDialog(FOO::IDD, pParent)
{
//{{AFX_DATA_INIT(FOO)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pSomeObject = NULL;
m_bSomeBoolean = false;
m_iSomeInt = 0;
m_sSomeString = "";
}
It is not importaint that it be a dialog class, this is just where I am seeing it used. I am just wondering what the advantages of one over the other are, or if there are advantages?
Thanks,
Troy
FOO::FOO(CWnd* pParent /*=NULL*/)
: CDialog(FOO::IDD, pParent),
m_pSomeObject( NULL ),
m_bSomeBoolean( false ),
m_iSomeInt( 0 ),
m_sSomeString( "" )
{
//{{AFX_DATA_INIT(FOO)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
Now m_pSomeObject, m_bSomeBoolean, m_iSomeInt, and m_sSomeString are member variables of the class. So, they are being initialized. Is this method of defining a constructor better than doing it this way?
FOO::FOO(CWnd* pParent /*=NULL*/)
: CDialog(FOO::IDD, pParent)
{
//{{AFX_DATA_INIT(FOO)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pSomeObject = NULL;
m_bSomeBoolean = false;
m_iSomeInt = 0;
m_sSomeString = "";
}
It is not importaint that it be a dialog class, this is just where I am seeing it used. I am just wondering what the advantages of one over the other are, or if there are advantages?
Thanks,
Troy