this question is more theory than useful, but i'm having trouble understanding this:
if i have three .cpp files, main.cpp class1.cpp and class2.cpp
i want to declare a global variable in main class1 and class2. i initialize it in main, and just use it in class1 and class2
main:
float pi = 3.14159;
class1:
extern float pi;
class2:
extern float pi;
but, what if i want to use the same global variable name and use it in main and class1, but give it a different value in class2?
main:
string type = green;
class1:
extern string type;
class2:
??
i want it to be global, and i want it to be a string named "type" but, for example, set equal to orange.
please explain! thanks
if i have three .cpp files, main.cpp class1.cpp and class2.cpp
i want to declare a global variable in main class1 and class2. i initialize it in main, and just use it in class1 and class2
main:
float pi = 3.14159;
class1:
extern float pi;
class2:
extern float pi;
but, what if i want to use the same global variable name and use it in main and class1, but give it a different value in class2?
main:
string type = green;
class1:
extern string type;
class2:
??
i want it to be global, and i want it to be a string named "type" but, for example, set equal to orange.
please explain! thanks