LPVOID pClassObj;
if (condition 1)
{
CClass1 *pClassObj = new CClass1();
}
elseif (condition 2)
{
CClass2 *pClassObj = new CClass2();
}
else
{
return ERROR
}
if (pClassObj == NULL) return ERROR;
pClassObj->Method1();
pClassObj->Method2();
return SUCCESS;
But it can't compile ( pClassObj is not a class type )
Because CClass *pClassObj = new CClass(); is between braces I guess (out of scope). Is there a way to do something like this ?
Is there a relationship between CClass1 and CClass2? For example, are they derived from a common base class?
No. Well they are COM objects so they derived from IUnknown but they are unrelated to each other except for 2 methods of the same name.
I have a plan b which satisfy my needs but it would be a bit more elegant if it fits as plan a. I'm not a c++ guru so if it hits a limit I can do it some other way. Do not waste to much time on it ;-)