Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initializing Class member pointers 1

Status
Not open for further replies.

SDowd

Programmer
Nov 11, 2005
91
0
0
US
Hey everyone,
I was wondering if anyone could tell me the difference between
Code:
ClearDialog::ClearDialog():
m_pIDTextCtrl(NULL),
m_pDispatchComboBox(NULL),
m_pCauseComboBox(NULL),
m_pCureComboBox(NULL),
m_pTextBox(NULL)
{

}

and:

Code:
ClearDialog::ClearDialog()
{
m_pIDTextCtrl = NULL;
m_pDispatchComboBox = NULL;
m_pCauseComboBox = NULL;
m_pCureComboBox = NULL;
m_pTextBox = NULL;
}

Is there any advantage one way or the other for either approach to initializing member pointers in the constructor?

Thanks
 
Thank you for your reply. I think I've given myself a new standard to follow.
And Just as a side note.. I've been frequenting this site for some time now, and you seem to be one of the main contributers to this forum.. so on behalf of the ones you have helped: Thank you.
 
By the way, in the case of pointers initialized to null (and other built-in types), you really won't get a performance benefit. However, you should still use the initializer list for consistency.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top