Compilation error
//Code: // Enter the width first, followed by an Enter, followed by the height #include <iostream> using namespace std; class Shape{ public: virtual void Draw() = 0; virtual int getArea() = 0; virtual int getEdge() = 0; }; class Rect : public Shape{ private: int width, height; public: Rect(int width, int height){ this -> width = width; this -> height = height; } ~Rect(); void Draw(){ int i, j; for(i = 0; i < height; i++){ for(j = 0; j < width; j++){ cout << "*"; } cout << endl; } } int getArea(){return width * height;} int getEdge(){return (2 * width) + (2 * height);} }; class Square : public Shape{ // Also derived from Rect but let's ignore that private: int length; public: Square(int length){ this -> length = length; } ~Square(); void Draw(){ int i, j; for(i = 0; i < length; i++){ for(j = 0; j < length; j++){ cout << "*"; } cout << endl; } } int getArea(){return length * length;} int getEdge(){return 4 * length;} }; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; Shape *shape1 = new Rect(a, b); Shape *shape2 = new Square(c); //compilation error. shape1 -> Draw(); cout << "Perimeter is " << shape1 -> getEdge() << endl; cout << "Area is " << shape1 -> getArea() < endl; shape2 -> Draw(); cout << "Perimeter is " << shape2 -> getEdge() << endl; cout << "Area is " << shape2 -> getArea(); return 0; }