-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPRA_26
57 lines (57 loc) · 808 Bytes
/
PRA_26
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
/* A program to demonstrate multiple inheritance */
#include<iostream>
using namespace std;
class Base
{
protected :
int b;
void getBase()
{
cout << "Enter Base : ";
cin >> b;
}
};
class Exponent
{
protected :
int n;
void getExponent()
{
cout << "Enter Exponent : ";
cin >> n;
}
};
class Power : public Base , public Exponent
{
public:
float p;
Power()
{
getBase();
getExponent();
solPower();
cout <<b<< " raise to "<<n <<" = "<< p;
}
void solPower()
{
p=1;
for(int i=0;i<n;i++)
{
p*=b;
}
}
};
int main()
{
Power P;
return 0;
}
/*
Output:
Enter Base : 5
Enter Exponent : 5
5 raise to 5 = 3125
--------------------------------
Process exited after 16.73 seconds with return value 0
Press any key to continue . . .
*/