Anyways, I am teaching myself C++ with "Beginning C++ game programming" (Dawson). I have actually found it rather easy so far (chapter 8 and 1 1/2 months). Now I am trying to finally branch out a bit on my own and have encountered a problem.
I am makng a text RPG and am trying to make the inventroy with a vector. I declare with the following code:
vector<string> inventory;
inventory.push_back("sword");
inventory.push_back("shield");
inventory.push_back("armor");
This compiles fine, so I assume it is correct. But two functions later, I use this code to display the inventory:
for (int i = 0; i < inventory.size(); ++i)
cout << inventory;
I use microsoft visual 2010 express and it says "error C2065: 'inventory' : undeclared identifier". What have I done wrong?
Thank you!