I just followed TheNewBoston's tutorials and made another class and header, but when I include header and write strings in cpp file, nothing happens. I am using Visual C++, Visual Studio 2013, I am on Windows 7, I tried moving header and cpp file in other folder but when I did ../, etc it could not even find header, anyways I need detailed and adapted answer, Thanks. and heres header file:
1 2 3 4 5 6 7 8 9 10
#pragma once
class TroopNames
{
public:
TroopNames();
~TroopNames();
};
(Sorry for silly code)
When I try to use one of these strings in main cpp, it does not work, I am not sure what I left out, or what I need to do but, yeah.
I am little confused well, no I didn't, I did it so it won't take too much space in main cpp, but I rather keep those variables in maincpp than declaring them as extern, what would be advantage of that declaring them as extern? I mean, you can keep them in same class then?
Right now your variables are not in class. They are global variables shared by whole program.
You cannot access them unless you declare them extern in using compilation unit or you shadow them with another declaration (and use that declaration instead)
Just show how do you access them in main() and I tell you what is actually happening and why.