By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,107 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,107 IT Pros & Developers. It's quick & easy.

order of initialization of static class objects

P: n/a
Hi all! Does the standard say anything about the order of initialization of
static class objects? For example:

class A{};

class B
{
static A a;
};

class C
{
static A a;
};

//...

Is it specified that B::a will always be initialized earlier than C::a?

Ben
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
No, it depends on the implementation:

If in classes.cc, you have:
// ...
A C::a;
A B::a;
// ...
C::a will be initialized before B::a.

If the two class statics are defined in two different
implementation files, then the order of initialisation
is unspecified by the standard.

Stephan

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.