Question: Write and analyze the following C++ code #include using namespace std; class Animal { public: virtual void show () = 0; //Pure virtual function

Write and analyze the following C++ code #include using namespace std; class Animal { public: virtual void

Write and analyze the following C++ code #include using namespace std; class Animal { public: virtual void show () = 0; //Pure virtual function declaration. }; class Man: public Animal { public: void show () { cout < < "Man is the part of animal husbandry " < < endl; } int main() { Animal *aptr; //Base class pointer //Animal a; Man m; //derived class object creation. aptr = &m; aptr->show(); return 0; } [Paste code and program output]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The C code youve shown implements a simple example of polymorphism one of the key concepts in object... View full answer

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!