C
Cheng Mo
I know global varaibles should always be avoided. I asked this question
just for deep insight about C++.
If global variables are distributed among different source code files,
what's the initialziation sequence of these varaibles. Say,
Foo g_fooMain in main.cpp;
Foo g_hello in hello.cpp;
Foo g_bye in bye.cpp;
and main.cpp has code
#include "hello.h"
#include "bye.h"
Does C++ defines the sequence? or it is compiler-dependent?
Thanks.
just for deep insight about C++.
If global variables are distributed among different source code files,
what's the initialziation sequence of these varaibles. Say,
Foo g_fooMain in main.cpp;
Foo g_hello in hello.cpp;
Foo g_bye in bye.cpp;
and main.cpp has code
#include "hello.h"
#include "bye.h"
Does C++ defines the sequence? or it is compiler-dependent?
Thanks.