You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<cstdio>classC {
public:C(constchar *s) {
printf(s);
}
};
static C b("b");
namespaceD {
static C d("d");
}
intmain(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.
The text was updated successfully, but these errors were encountered:
Blackhex
changed the title
Object constructor not called on static objects
Object constructor not called on global static objects
Aug 14, 2024
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.The text was updated successfully, but these errors were encountered: