* markww:
Hi,
I put a static member variable in my class.
class CMine {
static int m_nCount;
};
How do I initialize it to zero?
Like
int CMine::m_nCount = 0;
Or you could just declare it with no explicit initialization since
static variables are zero-initialized before any other initialization
(and there is no other initialization for an 'int' with no explicit
initialization).
By the way, I'd remove the Microsoft Hungarian notation prefixes. For
the class the prefix adds more to write and reduces readability. For
the static variable the prefix is directly misleading.
I can't do that in the constructor of the class can I?
Technically you can, but that would in practice constrain the usage of
the class, and it would be unexpected.
Won't that keep setting it to zero everytime a new instance is created?
Yes.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?