Question: Having the following drafts for the classes Line, Square, and Cube class Line { private: int length; public: // add functions here }; class Square:

Having the following drafts for the classes Line, Square, and Cube class Line { private: int length; public: // add functions here };

class Square: public Line { private: int high; public: // add functions here };

class Cube: public Square { private: int deep; public: void sayHello() { cout << I am a Cube;} // add functions here };

int main() { Line *father; Cube cubi; father = &cubi; father->sayHello(); // make this line print I am a Cube return 0; }

Add the necessary code to make polymorphism work here. And, make this line father->sayHello(); print I am a Cube when execute

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 Databases Questions!