You are viewing a single comment's thread. Return to all comments →
using namespace std;
class Rectangle { public: int width; int height; virtual void display() { cout << width << " " << height << endl; } }; class RectangleArea : public Rectangle { public: void read_input() { cin >> width; cin >> height;
} void display()override { Rectangle::display(); cout << width * height << endl; }
};
int main() { RectangleArea rectangle1; rectangle1.read_input(); rectangle1.display(); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Rectangle Area
You are viewing a single comment's thread. Return to all comments →
using namespace std;
class Rectangle { public: int width; int height; virtual void display() { cout << width << " " << height << endl; } }; class RectangleArea : public Rectangle { public: void read_input() { cin >> width; cin >> height;
};
int main() { RectangleArea rectangle1; rectangle1.read_input(); rectangle1.display(); return 0; }