-
Notifications
You must be signed in to change notification settings - Fork 83
/
OOP .cpp
48 lines (46 loc) · 746 Bytes
/
OOP .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
#include<iostream>
using namespace std;
class Rectangle()
{
private:
int length;
int breadth;
public:
Rectangle()//constructor
{
length=1;
breadth=1;
}
Rectangle(int l,int b);//parametrised constructor
int area();
int perimeter();
int getlength(); return length;
void setlength(int l); length=l;
~Rectangle()
};
Rectangle::Rectangle(int l,int b)
{
length=l;
breadth=b;
}
int Rectangle::area()
{
return length*breadth;
}
int Rectangle::perimeter();
{
return 2*(length+breadth);
}
Rectangle::~Rectangle()
{
cout<<"The role of destructor has come:"<<endl;
}
int main()
{
Rectangle r;
Rectangle (10,5);
cout<<r.area()<<endl;
cout<<r.perimeter()<<endl;
r.setlength(20);
cout<<r.getlength();
}