This might be a very simple thing to most of the programmers. But I thought of writing this in my blog as I spent half a day finding a way to access a variable in .cpp from another .cpp(without importing the .h or defining as public inside a class.)
suppose the variable we want to access is defined as follows in the original file,
if you want to access this from another .cpp simply you have to do is define it with extern key word in that file,
i.e extern bool flag;
both declarations refer to the same variable "flag".