Hi.
I have some trouble understanding the linking process and hence this related question.
Lets say I need a global variable that is needed by every single source file in my project.
I would create a constants.h
header and put extern const int var;
in it. In corresponding source, constants.cpp
, I would put const int var = 5;
.(oh and a question here, wouldn't just int var = 5;
work?)
Then, every source file would get var
. (supposedly)
Will source files, that don't #include "constants.h"
get access to var
?
If so, how would it possible if there is no link between the 2 files?