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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -