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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -