Tony Johansson wrote:
Hello!
Is it possible to put the body below which is the instansiating of Test in
the initialize list in some way.
CEx07aView::CEx07aView()
{
m_pDlg = new Test(this);
}
Simple
CEx07aView::CEx07aView() : m_pDlg(new Test(this))
{
}
But some compilers might give you warnings with this code. This is
because you are using 'this' before the object it is refering to has
been constructed, which is potentially a dangerous situation. I think I
would usually prefer this code
CEx07aView::CEx07aView() : m_pDlg(0)
{
m_pDlg = new Test(this);
}
The main difference between all three sets of code is what would happen
if new Test(this) threw an exception.
john