Item Base Class questions

I made a base class for all of my items that will be able to picked up in the game world. I have an enum in my header file so I can set the type of item it is such as weapon, ammo, or a usable item such as a first aid kit. How would i set the default type of item in the constructor. The enum is called ItemTypes. Is this the best way to do this or should I just go by the class types and forget enums when it comes to constructing the players inventory?

I dont know if i undertood. My English is not good, but you can simple set the default value in you Item class constructor


EItemType ItemType ;

on “Apple.cpp” constructor:
ItemType = EItemType::Food;

and use the ItemType variable for look the type of the item.

Personally I prefer not to use enums in this case but use a class structure like this:

Interactive -> Item -> food -> etc
Interactive -> Item -> weapon -> weaponInstant / rocket launcher etc

among other things, I can specify special behavior for each type of item to an event with polymorphism, for example the “Use()” function

You can use a cast to get the “Type” also right?

Yes, you can try casting to a type. If it’s NULL, it’s not that class.