The order of #include is respected. It has absolutely nothing to do with the order of initialization of global variables across multiple compilation units, however.
Why doesn't it respect the order? I should think that making it chaotic would be more difficult than just linearly assembling the code...
But what is that order?
I refer you to my previous question:
I have a project with 3 files, A.cpp, B.cpp, and C.cpp, which are linked together to create an application. In which order would this hypothetical global-scope code in these 3 files execute?
Assume "A.cpp" contains my main function, and B.cpp and C.cpp each define a class that is used by my application. What is the "linear order" of A, B, and C? What if, as is more likely in any decent-sized project, there are 10 files, each defining a class? 20? 100?
#include is used to include a header file at compilation time. The header file will contain the information other translation units (i.e. files) will need in order to use the symbols contained in it, but no more. It (ideally) won't contain the actual code for the functions/methods it declares.
Linking is a different issue - it happens after compilation, and it takes the object files that were created during the compilation, and links them together so that the compiled code in one file can access compiled code in other files.
Really, we're into basic C++ tutorial stuff here. If you're interested, you'd be better off finding an existing tutorial and reading it, rather than asking us to regurgitate one for you.
#include "ReadFile.cpp"
#include "Data.h"
Area Window;
Area View;
Camera cam;
#include "ControlEvents.cpp"
#include "Controls.cpp"
'Controls' relies on 'ControlEvents', 'Data.h', and the globals in the centre. Are you telling me that if I keep compiling this without changing anything, one time 'Controls' might try to use "cam", but it hasn't been initialized yet in this particular compilation? I just can't see that being true, but that's what I'm getting from it.
No. I'm saying that if cam relies on View, you cannot rely on View having been created before cam.
I don't mean to sound rude, but the fact that you have #include statements including .cpp files indicates to me that you don't really understand the basics of C++. I reiterate my previous statement - there's already loads of C++ tutorial material out there to introduce you to the basics of the language, if you're interested. There's no need for us to repeat it here.
It might work, if the code in the included files doesn't lead to anything problematic, like multiple definitions of symbols. But that's only if you're lucky.
I'm so confused now
:?
How do I include them if I don't include them?
As I've already explained, you link against them. Or, rather, you link against the object files that the compiler creates when compiling them.