   Inventory/Item design needing suggestions
  I am working on an inventory system for a RPG, and am running into a problem in the item/inventory design.So far I have a base class Item, which Weapon, Armor and Consumable derive from. They all have the same basic functionality and stats, but each derived class has additional specific variables, with accompanying set/get functions.I also have a base class Inventory, which PlayerInventory, TeamInventory and ShopInventory derive from. Inventory has a std::vector<Item*>, and in turn so do the derived classes.The problem is that PlayerInventory points to all Armor objects using Item pointers, so using this I cannot access the members that Armor has but Item does not.So, I've got a couple options that I know of. I can just make PlayerInventory be a base class of its own, and have a std::vector<Armor*> instead of the Item* one. Or, I can add all of the Armor specific set/get functions as ( = 0) virtuals in the Item class. Both would work, but they seem like shady decisions to force the design, and I like that I am inheriting a lot of common functionality. I Googled, but couldn't find a suitable solution to use derived class functions from base class pointers. Any suggestions?   
Quote:couldn't find a suitable solution to use derived class functions from base class pointers. Well it's quite easy to access the functions through a pointer cast, but at first you have to actually know which of your items are armor items and which aren't.Do you have some way to identify what an item actually is from an Item* pointer? You'd either need to have type information stored in the class, or store them separately (could an inventory have a vector of weapons and a vector of armor instead of just a vector of items?)To access the methods is quite simple:if(items.GetType() == Items::ARMOR){    static_cast<Armor*>(items)->DoSomethingArmorSpecific();};  You can do a dynamic_cast on the Item pointer to a Armor pointer and that would allow you to access the Armor methods. If the Item pointer is not a Armor instance it will return NULL. Your Item pointer is basically and interface. You can Google interface for more information.if(dynamic_cast<Armor*>(ItemList) != NULL){   dynamic_cast<Armor*>(ItemList)->SomeArmorFuntion();}just a word of warning dynamic_cast are slower than static casts   ;  I do have an enum ItemType in the Item's variables that denotes the type, so I can use that if need be. I've never used casting beyond:float this = 1.0f;int that = (int)this;I didn't think to use it on pointers. Now I have 100 questions on it, but I'll do some research on my own before I do ;) Thanks guys.