M
Michael
Hi All,
if I have a class BaseClass and two derived classes Class1 and Class2 and I
don't know which derived class I will need, is it ok for me to do the
following:
BaseClass* base;
if(some_test){
base = new Class1;
} else {
base = new Class2;
}
I know it works, but is it somehow dodgy? I have a feeling there is a better
way but I'm not sure what to search for.
Thanks for your help.
Regards
Michael
if I have a class BaseClass and two derived classes Class1 and Class2 and I
don't know which derived class I will need, is it ok for me to do the
following:
BaseClass* base;
if(some_test){
base = new Class1;
} else {
base = new Class2;
}
I know it works, but is it somehow dodgy? I have a feeling there is a better
way but I'm not sure what to search for.
Thanks for your help.
Regards
Michael