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
Get step-by-step solutions from verified subject matter experts
