If OBJA.FA() returns a string wit a name in it and you mean to create an object based on that name, then you need to write a factory class that will create the object and return a pointer to it. Most likely, you will need polymorphism:
-
class Factory
-
{
-
public:
-
Base* CreateObject(string& arg);
-
};
-
Base* Factory::CreateObject(string& arg)
-
{
-
if (arg == "babu198649")
-
{
-
-
return new Babu;
-
}
-
}
-
Another way to do this is to use a different kind of factory that does not require polymorphism. This is called a parameterized factory:
-
class Factory
-
{
-
public:
-
Babu* CreateBabu();
-
};
-
Babu* Factory::CreateBabu()
-
{
-
-
return new Babu;
-
}
-
You use the parameterized factory by calling the correct create method:
-
Factory f;
-
string arg = OBJA.FA();
-
Babu* obj = 0;
-
if (arg = "babu198649")
-
{
-
obj = f.CreateBabu();
-
}
-
You can read up on the factory design pattern in a design patterns textbook.