I have the following code, with a class hierarchy structure of a base class Base, and several derived class Derived1, Derived2, Derived3...so on.
switch(i){
case 1:{
Derived1* d1;
generateD1(d1);
otherFunc(d1); //function signature is otherFunc(Base*)
break;
}
case 2:{
Derived2* d2;
generateD2(d2);
otherFunc(d2);
break;
}
... //goes on for many cases
}
How can I use the inheritance mechanism to improve the above codes?