470,572 Members | 2,561 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,572 developers. It's quick & easy.

A paragraph from Bjarne stroustrup's Book

7
How to understand the following paragraph from Bjarne stroustrup's The C++ Programming Language?
9.4.1:
In principle, a variable defined outside any function (that is, global, namespace, and class static variables) is initialized before main() is invoked. Such nonlocal variables in a translation unit are
initialized in their declaration order (§10.4.9). If such a variable has no explicit initializer, it is by default initialized to the default for its type (§10.4.2). The default initializer value for builtin types and enumerations is 0 . For example:

Does it mean:
class Example
{
static int DataMember;
}
DataMember automatically intialized to 0.
This seems to be wrong.
Feb 15 '08 #1
1 1639
weaknessforcats
9,208 Expert Mod 8TB
Youe have just declared a static member variable but you haven't defined it.

When you define it, the default initialization will be 0.

You might read this: http://www.thescripts.com/forum/thread737451.html.
Feb 15 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Teddy | last post: by
1 post views Thread by blangela | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.