Do you really want to pass the name, i.e. a string? Then you'd have to provide the Item*-classes with a corresponding function, e.g.
class ItemOne {
static std::string name();
};
ItemGenerator *someItem = new ItemGenerator(ItemThree::name());
Or are you looking for templates? You have different possibilities there: make a class template, maybe derived from an ItemGenerator base class:
class AbstractItemGenerator { /* ... */ };
template <class Item>
class ItemGenerator {
ItemGenerator();
};
ItemGeneratorBase *someItem = new ItemGenerator<ItemTwo>();
Or make only the construtor templated - you cannot explicitly specify the parameter, so use argumet deduction:
//take 1: use pointers
class ItemGenerator {
template <class Item>
ItemGenerator(Item* dummy);
};
ItemGenerator *someItem = new ItemGenerator((ItemFour*)NULL);
//take 2: use a tag struct
template <class I>
struct ItemTag{};
class ItemGenerator {
template <class Item>
ItemGenerator(ItemTag<Item> tag);
};
ItemGenerator *someItem = new ItemGenerator(ItemTag<ItemOne>());
I am not sure if one of these suits your needs. Maybe elaborate what you want to use this for.
ItemGeneratorgoing to do with the class name or thestaticmember function?