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 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
The C code youve shown implements a simple example of polymorphism one of the key concepts in object... View full answer
Get step-by-step solutions from verified subject matter experts
