#include <cstdio>
class C {
public:
C(const char *s) {
printf(s);
}
};
static C b("b");
namespace D {
static C d("d");
}
int main(int argc, char **argv) {
static C c("c");
C a("a");
}
It outpus ca instead of bdca (or whatever is the order defined by the standard) which means that the constructors for global static objects are not called (both namespaces and non-namespaced). The local static objects' constrcutor get called.
Considering the following C++ code:
It outpus
ca
instead ofbdca
(or whatever is the order defined by the standard) which means that the constructors for global static objects are not called (both namespaces and non-namespaced). The local static objects' constrcutor get called.