Lets say I have a basic Item Class such as this:
class Item
{
public:
int x,y;
}
and then I have two other classes that are derived from that class:
class Weapon : public Item
{
public:
int type;
char name;
}
class Armor : public Item
{
public:
int type;
char name;
}
Then I go and create an array to store the inventory of the characters like this:
Item inventory[10];
Armor breastplate;
inventory[1] = breastplate;
but that give me an error of unable to convert Armor to Item. Any ideas what I am doing wrong? I have even tried using this:
inventory[1] = (Item)breastplate;
but that does not work either.
Any help would be appreciated.