c++ - Defining Global Variables Between Two .cpp Files -
how can share/globalize bool variable between a.cpp , b.cpp neither of them include other ones .h file?? have other joint header files not each other's. can define global variables inside shared headers?
thanks
can define global variables inside shared headers?
no.
in a.cpp (or) b.cpp write,
int gvariable = 10;
remember write above definition in 1 source file or else linker complain of multiple symbols if write in both source files.
and in common header of a.cpp, b.cpp write,
extern int gvariable;
Comments
Post a Comment