Hey guys,
If I declare a global variable in, say, "main.cpp", then try to access it in, say, "file2.cpp", it won't work (thats right, right?). Earlier on, I read in a book that you can declare all of your global variables in a header, then include it in another file, then declare it using "extern *variablename*" in the second file... then, it said something like you can include the header in yet another file and use extern again, and then both files will have access to the globals. I tried it, but then it gave me an error:
Missing ';' before identifier 'Ship' //this was in globals.h
That usually means that 'Ship''s header hasn't been included yet... but it WAS. So then I tried not including the header with the globals (as in, I included it in 'main.cpp' but not in the second file), and then deleted all the stuff in the second file that depended on these global variables, and then it worked. Does anybody know why? :confused: (Or, for that matter, how I can share the global variables between files?)