I have a pointer to an object which i will be using in one method. but i need to use the same pointer again in another method how can i achieve this without declaring as global object. This is part of my dynamic biding achievement Shape is the parent class and the Rectangle is the child class.
int main(){
switch (choice){
case 1:
create();
break;
case 2:
process();
break;
}
}
create(){
Shape *shape[3];
shape[0]=&objRectangle;
}
process(){
for(int i=0;i<3;i++){
shape->print; // I want to acchieve like this.
}
Now i cant do this cause, the shape object is gone once it exits the create process. Please assist.