First of all: DO NOT USE GLOBAL VARIABLES... Their "ease of use" just lead to tons of problems. Believe me, I maintained a sofware made by a previous guy in my company. He liked global variables and because of that it took me months to understand some strange bugs.
Even though you still want to use them:
- Make sure the
extern
keyword is used in the .h
- Make sure a local variable (in your file or function) has not the same name.
- Make sure the type of the variable in the .cpp matches the type of its extern declaration.
- Make sure the .cpp file that contains the variable is part of your project.
If this doesn't solve the problem. Give some code.
------
OK. You defined
n
and
D
in
basic.cpp but you still need to define
oilvariables
and
vinegarvariables
: I don't see them in your code.
------
Your are taking the values from the user, but where the values will be kept? You need to define the variables like the other ones (in basic.cpp for example):
int oilvariables;
int vinegarvariables;
int n = ...;
int D = ...;
I will suggest one more time to not use global variables.
You don't need them in your code. Use functions, parameters, and return values from your functions instead.