Question: P 9 . Consider the following inheritance: class One { public: void whoami ( ) { cout < < One ; } } ; class

P9. Consider the following inheritance:
class One{
public:
void whoami(){cout<<One ;}
};
class Two: public One{
public:
void whoami(){cout<<Two ;}
};
class Three: public Two{
public:
void whoami(){cout<<Three;}
};
int main(){
One dog;
Two cat;
Three rat;
One * objPtr[3];
objPtr[0]=&dog;
objPtr[1]=&cat;
objPtr[2]=&rat;
for(int i=0; i<3; i++)
objPtr[i]->whoami();
return 0;
}
What is the output?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!