I have to call a static functions inside a class(say UserApp) which returns static value. Class Definition and declaration done in 2 files.
File1.h:
userApp(){
static int* foo;
}
file1.cpp:
{
int* userApp::foo = 0;
...
.
.
foo = somevar;
}
The same class(userApp) is implemented in file2 and to avoid linkage error I'm forced to declare and define the static variable in file2 as well.
In file 2.cpp as userApp::foo is initialized to 0 , the return value of function getFoo is always zero.
I need the value associated to foo in file1. Is there any way I can avoid defining static variable in file2? Thanks in advance.