Why not just use a std::vector for your inventory class?
A simple inventory is just a collection of items.
1 2 3 4 5 6 7 8
|
typedef vecotr<Item> Inventory;
class Player
{
...
Inventory inventory;
...
};
|
If at some point you want your inventory to have properties other than a simple collection class, you can replace the typedef with an Inventory class which inherits a vector:
1 2 3 4
|
class Inventory : public std::vector<Item>
{
...
};
|
BTW, this line is faulty:
|
inventory[10] = new inventory[inventoryLimit];
|
new returns a pointer to an array of 10 inventories (assuming inventoryLimit is 10). inventory[10] is an array of inventories, not an array of pointers. This line won't compile.
Also, inventory[10] is not a valid reference. subscripts in C++ are 0 based, therefore the valid elements are inventory[0] to inventory[9].
Also how should I do the enemy class? |
Any way you want. You're limited only by your imagination.
If your Player and Enemy have common attributes, you might want to make a Character class with contains the common attributes such as stamina and health, then have both Player and Enemy inherit the Character class.
how would I make the map? |
Again, you're limited only by your imagination. What to you want the map to represent? A simple 10x10 character grid? Rooms in a dungeon? Tiles in a world (ala Minecraft)?