-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_sep_func.cpp
59 lines (56 loc) · 1.14 KB
/
class_sep_func.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
#include <iostream>
using namespace std;
class rectangle{
private:
int length;
int breadth;
public:
rectangle();
rectangle(int l, int b);
rectangle(rectangle &r);
int getlength() { return length; }
int getbreadth(){return breadth;}
void setlength(int l);
void setbreadth(int b);
int area();
int perimeter();
bool isSquare();
~rectangle(); //destructor
};
int main()
{
rectangle r1(20, 20);
cout<<"Area "<<r1.area()<<endl;
if(r1.isSquare())
cout << "yea square"<<endl;
}
rectangle :: rectangle(){
length = 1;
breadth = 1;
}
rectangle ::rectangle(int l,int b){
length = l;
breadth = b;
}
rectangle ::rectangle(rectangle &r){
length = r.length;
breadth = r.breadth;
}
void rectangle ::setlength(int l){
length = l;
}
void rectangle ::setbreadth(int b){
breadth = b;
}
int rectangle ::area(){
return length*breadth;
}
int rectangle ::perimeter(){
return 2*(length+breadth);
}
bool rectangle ::isSquare(){
return length ==breadth;
}
rectangle :: ~rectangle(){
cout << "Rectangle Destroyed";
}