-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut47.cpp
61 lines (53 loc) · 1.49 KB
/
tut47.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
// Solution to Exercise on Cpp Inheritance
#include<iostream>
#include<cmath>
using namespace std;
class SimpleCalculator{
int a,b;
public:
void getdatad(){
cout<<"Enter the value of number a . "<<endl;
cin>>a;
cout<<"Enter the value of number b . "<<endl;
cin>>b;
}
void Performoperationsd();
};
void SimpleCalculator :: Performoperationsd(){
cout<<"The sum of a and b is "<<(a+b)<<endl;
cout<<"The subtraction of a and b is "<<(a-b)<<endl;
cout<<"The division of a and b is "<<(a/b)<<endl;
cout<<"The multiplication of a and b is "<<(a*b)<<endl;
}
class ScientificCalculator{
int c,d;
public:
void getdatae(){
cout<<"Enter the value of number 1. "<<endl;
cin>>c;
cout<<"Enter the value of number 2. "<<endl;
cin>>d;
}
void Performoperationse(){
cout<<"The value of cos(c) is "<<cos(c)<<endl;
cout<<"The value of sin(c) is "<<sin(c)<<endl;
cout<<"The value of exp(c) is "<<exp(c)<<endl;
cout<<"The value of tan(c) is "<<tan(c)<<endl;
}
};
class HybridCalculator : public SimpleCalculator , public ScientificCalculator{
};
int main(){
// SimpleCalculator Phone;
// Phone.getdatad();
// Phone.Performoperationsd();
// ScientificCalculator idea;
// idea.getdatae();
// idea.Performoperationse();
HybridCalculator Boot;
Boot.getdatad();
Boot.Performoperationsd();
Boot.getdatae();
Boot.Performoperationse();
return 0;
}