Hi all,
I've come across a syntax I don't understand a few times, and maybe some of you can help. Here is an example:
The "g_pString(NULL)" I don't understand. I know that is sets the variable to NULL, but I don't understand why it's allowed after the constructor and the ":" that separates them confuses me even more.
Can anyone explain this to me? I haven't been able to find good information about this yet. Are there any advantages to using this instead of initializing the variable in the body of the function?
Thanks!
--Eric
I've come across a syntax I don't understand a few times, and maybe some of you can help. Here is an example:
- Code:
CLASS MyClass
{
public:
TCHAR *g_pString;
// constructor
MyClass(void) : g_pString(NULL)
{ }
};
The "g_pString(NULL)" I don't understand. I know that is sets the variable to NULL, but I don't understand why it's allowed after the constructor and the ":" that separates them confuses me even more.
Can anyone explain this to me? I haven't been able to find good information about this yet. Are there any advantages to using this instead of initializing the variable in the body of the function?
Thanks!
--Eric