Vector Inventory Pointers

hello, i have been wondering something about vectors..

(if anyone needs code let me know)

alright heres my question with a bit of an explination:

i have made an item class in its own header file. i also have made a player class in its own header file. they both have child classes of their own(doesnt matter much)

so heres my question:

is it possible to make a vector of the item class in the player class like this:


1
2
3
4
5
class Player
{
 vector<Item*> Inventory;
//other stuff
}



when i tried this out, i got an error saying that 'Item' was not declared i this scope.

so im wondering if this is the wrong way of doing this?

what im trying to do is make a vector for the items at the same time make it for only that player

it would be nice to provide some code explaining how. xD

thanks in advance
you need to tell Player that Item exists by forward declaring it
class Item;
before the Player class definition
hm..that makes sense. now would i have to do that for each child class also?

if so then its no big deal, thanks ima test this out
Just in each separate header file with class declarations based on your base class.
Topic archived. No new replies allowed.