I am wanting to have a variable that is accessible from any module, so that the 'main' function in moduleA(modA.cpp) can set that value of variable 'bob', while function 'check_status' in moduleB(modB.cpp) can check to see if the value of 'bob' is five. This is just a very simplified version of what I am really trying to do but it should give the basic idea of what I am attempting. I know that one can use a header to declare function that is not in the same module, but when I try doing this (after including the file in both modules) the program won't compile, giving me an error message that says that the variable has been declared multiple times. I know how to do this in VB and QuickBasic, but I can not seem to get it to work in C++. I have not tried using pointers, but I think this might be a way to accomplish what I am attempting, because I would prefer to just create one variable and use it through the whole program, regardless of which module the function is located.
- JLBShecky