Originally Posted by
Mr.Pink
well the example is not what I'm realy trying to do. Basically I want to be able to create a class name by whatever input the user has given me.
If I'm understanding this right, you want a factory class or function.
The following is a very simplistic example with the problem that, whenever you create a new class of Animal, you have to modify the function;
Code:
std::auto_ptr<Animal> AnimalFactory(const std::string &type, const std::string &name)
{
std::auto_ptr<Animal> retval;
if (type == "Cat")
retval = new Cat(name);
else if (type == "Dog")
retval = new Dog(name);
// other known animals
return retval;
}