I have the following classes.
// My baseclass
class Item {
public:
virtual const std::string GetItemName() = 0;
};
// My derived class
class Shovel : public Item {
private:
static const std::string _ITEM_NAME = "tool_shovel";
public:
const std::string GetItemName(){
return _ITEM_NAME;
}
}
With this i can access the names of my Item
objects like this:
Item* myItem = new Shovel();
myItem.GetItemName(); // Returns "tool_shovel" ofcourse
I would now also like to access the name of an item without having an instance of it like this.
Shovel::GetItemName();
I know it is not possible to implement a virtual static function. but is there any way to implement this in a 'nice' way or is this more a problem in my concept?
Thanks for the help!