I had a question regarding how to solve the following in C++:
So, say I have 2 items. A Sword, and a Knife.
A sword's structure looks like the following:
baseItem > Equippable (Holds events and boolean checks) > Weapon (Same) > Sword
A knife's structure looks like the following:
baseItem > Equippable > Weapon > Knife
Most of my classes and functions that will be dealing with items (Inventory, Containers, the function that creates the Item Instances) will all be of type baseItem.
How do I specify functions such as:
baseItem createItem(int index, type itemType)
in such a way that I can return or cast back up to Sword/Knife? This is especially a concern with inventories as I will need to pull items from ItemSlot which will also hold objects of type baseItem, but will need to constantly check if they are Sword, Knife, etc.