I have something like this:
class Base
{
public:
static int Lolz()
{
return 0;
}
};
class Child : public Base
{
public:
int nothing;
};
template <typename T>
int Produce()
{
return T::Lolz();
}
and
Produce<Base>();
Produce<Child>();
both return 0, which, of course, is correct, but undesirable. Is there anyway to use an explicit declaration of the Lolz () method in the second class, or perhaps throw a compile-time error when using Produce<Child>()?
Or is it a bad OO design, and I have to do something completely different?
EDIT:
What I'm basically trying to do is to do something like this work:
Manager manager;
manager.RegisterProducer(&Woot::Produce, "Woot");
manager.RegisterProducer(&Goop::Produce, "Goop");
Object obj = manager.Produce("Woot");
or, in a more general sense, an external abstract factory that does not know the types of objects being created, so that new types can be added without writing more code.