-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path70. Perfect Class.cpp
96 lines (82 loc) · 1.37 KB
/
70. Perfect Class.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include<iostream>
using namespace std;
class rectangle
{
private:
int length, breadth;
public:
rectangle();
rectangle(int l,int b);
rectangle(rectangle(&rect));
void setLength(int l);
void setBreadth(int b);
int getLength();
int getBreadth();
int area();
int perimeter();
bool isSquare();
~rectangle();
};
int main()
{
rectangle r;
r.setLength(10);
r.setBreadth(10);
cout<<"Area of the rectangle is: "<<r.area()<<endl;
cout<<"Perimeter of the rectangle is: "<<r.perimeter()<<endl;
if(r.isSquare())
cout<<"It is a Square"<<endl;
else
cout<<"It is not a square"<<endl;
return 0;
}
rectangle::rectangle()
{
length = 1;
breadth = 1;
}
rectangle::rectangle(int l, int b)
{
length=l;
breadth=b;
}
rectangle::rectangle(rectangle (&rect))
{
length=rect.length;
breadth=rect.breadth;
}
void rectangle::setLength(int l)
{
length=l;
}
void rectangle::setBreadth(int b)
{
breadth=b;
}
int rectangle::getLength()
{
return length;
}
int rectangle::getBreadth()
{
return breadth;
}
int rectangle::area()
{
return length*breadth;
}
int rectangle::perimeter()
{
return 2*(length+breadth);
}
bool rectangle::isSquare()
{
if(length == breadth)
return 1;
else
return 0;
}
rectangle::~rectangle()
{
cout<<"Destroying the rectangle";
}