Compilation error | Sololearn: Learn to code for FREE!

0

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; }

1/20/2019 9:32:19 PM

mei

5 Answers

New Answer

+2

There's a cout line that is missing a '<' right before the endl in main

+2

Also next time you should make a playground code and post that instead mei

+1

oh, didn’t notice that lol thx

0

line 61, maybe?

0

😄 no problem. It happens to the best of us