-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rectangle Area
46 lines (38 loc) · 919 Bytes
/
Rectangle Area
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using namespace std;
class Rectangle
{
protected:
int width;
int height;
public:
Rectangle() : width(0), height(0) {}
Rectangle(const int w, const int h) : width(w), height(h) {}
virtual void display() const
{
cout << width << " " << height << endl;
}
};
class RectangleArea : public Rectangle
{
public:
RectangleArea() : Rectangle() {}
RectangleArea(const int w, const int h) : Rectangle(w, h) {}
void read_input()
{
char ch;
cin >> width >> height;
}
virtual void display() const
{
cout << width * height << endl;
}
};
int main()
{
RectangleArea r_area;
r_area.read_input();
r_area.Rectangle::display();
r_area.display();
return 0;
}