-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_1.cpp
57 lines (49 loc) · 932 Bytes
/
5_1.cpp
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
47
48
49
50
51
52
53
54
55
56
57
#include "iostream"
using namespace std;
struct Rectangle
{
float height, width;
void get_data();
void area();
};
class Rectangle1
{
float height, width;
public:
void get_data();
void area();
};
void Rectangle::get_data()
{
// cout << "enter the height of rectangle";
cin >> height;
// cout << "enter the width of rectangle";
cin >> width;
}
void Rectangle ::area()
{
cout << "area of rectangle is : " << height * width;
}
void Rectangle1::get_data()
{
// cout << "enter the height of rectangle";
cin >> height;
// cout << "enter the width of rectangle";
cin >> width;
}
void Rectangle1 ::area()
{
cout << "area of rectangle is : " << height * width;
}
int main()
{
Rectangle r1;
Rectangle1 r2;
r1.get_data();
r1.area();
cout << endl
<< "*********** using class *********" << endl;
r2.get_data();
r2.area();
return 0;
}