-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp12.cpp
More file actions
44 lines (41 loc) · 854 Bytes
/
exp12.cpp
File metadata and controls
44 lines (41 loc) · 854 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
41
42
43
44
#include<iostream>
using namespace std;
class c_polygon{
protected:
float area;
};
class c_rectangle : public c_polygon{
int length;
int breadth;
public:
c_rectangle(int length , int breadth){
this->length = length;
this->breadth = breadth;
area = length*breadth;
}
void display(){
cout<<"Area of Rectangle :"<<area<<endl;
}
};
class c_triangle : public c_polygon{
int a;
int b;
int c;
public:
c_triangle(int a , int b , int c){
this->a = a;
this->b = b;
this->c = c;
float s = (a+b+c)/2;
area = sqrtl(s*(s - a)*(s - b)*(s - c));
}
void display(){
cout<<"Area of Triangle :"<<area<<endl;
}
};
int main(){
c_rectangle a(10,20);
a.display();
c_triangle b(3,4,5);
b.display();
}