I have 3 cpp files that look like this
#include \"Variables.h\"
void AppMain() {
//Stuff...
}
They all use the same variables inside th
This is because the compiler compiles each .cpp
file separately, creating a .obj
file for each one. Your header appears to have something like:
int slider;
When this is included into each of your three .cpp
file, you get three copies of the int slider
variable, just as if you had declared it in each .cpp
file. The linker complains about this because you haven't have three different things with the same name.
What you probably want to do is change your header file to read:
extern int slider;
This tells the compiler that there is a slider
variable somewhere, but possibly not here, and lets the linker figure it out. Then, in one .cpp
file:
int slider;
gives the linker one actual variable to link.