I have my main.cpp file, and I have a slew of headers with class declarations and their accompanying .cpp files with their code. Take, for instance, Dummy1.h and Dummy1.cpp.
Now for Dummy1.cpp:
As it is, if I include Dummy1.h in the main.cpp file, everything works. However, if I want to declare something global, I cannot get all appropriate .cpp files to read it. If I try to declare a global variable in the Dummy1.h, I will get this compiler error using Visual Studio 2005:
char Dummy::RetChar(char arg1)
Shining Exp.obj : error LNK2005: "int giDum1" (?giDum1@@3HA) already defined in Dummy1.obj
C:\Documents and Settings\HP_Administrator\My Documents\Visual Studio 2005\Projects\Shining Exp\Debug\Shining Exp.exe : fatal error LNK1169: one or more multiply defined symbols found
If I declare it in Dummy1.cpp, the Dummy1.h file will not find it. (I am acutally using a considerably more complex header/source combination than this but I used these to simplify things.) If I declare the variable as global in main, I have that same problem. I need a .cpp file to be able to access an array of strings for purposes of object creation (character names), but the.h file needs to "see" that same array for prototypes or else it will be confused. I hope this is not too complex a question, lol. Thanks for any help you have!