-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcons.cpp
More file actions
40 lines (32 loc) · 754 Bytes
/
Copy pathcons.cpp
File metadata and controls
40 lines (32 loc) · 754 Bytes
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
#include <iostream>
using namespace std;
class Area
{
private:
int length;
int breadth;
public:
Area();
Area(int, int);
int AreaCalculation() { return (length * breadth); }
void DisplayArea(int temp) { cout << "Area: " << temp << endl; }
};
Area::Area():length(5),breadth(2) {
cout <<"Default Constructor" << endl;
}
Area::Area(int length, int breadth) {
this->length = length;
this->breadth = breadth;
cout <<"Parameterized constructor" << endl;
}
int main()
{
Area A1;
int area;
area = A1.AreaCalculation();
A1.DisplayArea(area);
Area A2(7,8);
area = A2.AreaCalculation();
A2.DisplayArea(area);
return 0;
}