i was moving forward on my little RPG, and came across the item system problem. up to now, i'm able to load an item list from an external file.
now, i want to make a system to handle all items in the game.
i tought in a single main vector for all items. and, then, inside a player class, a vector of pointers to the main vector of items.
but then i came across a problem: there are different kind of items, Weapon, Armor, and Others. all of these classes inherit some members of a base class ItemBase.
since everybody loves code, here is an example:
and I get the error:
class 'ItemBase' has no member named 'setAttack'.
this is true, as 'setAttack' is a member of 'ItemWeapon' class, which is inherited from BaseClass.
at this point, i did read this topic: http://www.cplusplus.com/forum/beginner/84621/
in which is said that "downcasting is a sign of bad design", so how to organize everything?
any suggestion is apreciated. i don't care if I have to change the whole system, if there are better solutions :)