W
werasm
Hi all,
I recently just stumbled upon this code. According to what
I see in the standard it should be fine, but I've always done
the initialization explicitly myself:
//.h
//...
struct X
{
static Y* m_Y;
};
//.cpp
//To initialise...
Y* X::m_Y; //...1
//as opposed to...
Y* X::m_Y = NULL; //...2
I now know (1) is correct as well (from various areas in the
standard).
I personally prefer (2) - probably because I've always done it that
way (I think I might have even had a problem with (1) a couple
of years back).
Any thoughts on this? Do I understand the standard correctly if I
say (1) is OK?
My rationale from std98:
- 8.5:5 - to zero initialize...
- 3.6.2 - storage for objects with static storage...
Which method do you consider preferred, or is it a matter of taste?
Regards,
Werner
I recently just stumbled upon this code. According to what
I see in the standard it should be fine, but I've always done
the initialization explicitly myself:
//.h
//...
struct X
{
static Y* m_Y;
};
//.cpp
//To initialise...
Y* X::m_Y; //...1
//as opposed to...
Y* X::m_Y = NULL; //...2
I now know (1) is correct as well (from various areas in the
standard).
I personally prefer (2) - probably because I've always done it that
way (I think I might have even had a problem with (1) a couple
of years back).
Any thoughts on this? Do I understand the standard correctly if I
say (1) is OK?
My rationale from std98:
- 8.5:5 - to zero initialize...
- 3.6.2 - storage for objects with static storage...
Which method do you consider preferred, or is it a matter of taste?
Regards,
Werner