-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp
More file actions
49 lines (45 loc) · 759 Bytes
/
cpp
File metadata and controls
49 lines (45 loc) · 759 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
45
46
47
48
49
#include<iostream.h>
using namespace std;
class hero{
protected:
int power;
public:
void set_power(int p){
power=p;
}
int get_power(int p){
return power;
}
};
class villan{
protected:
int power;
public:
void set_power(int p){
power=p;
}
int get_power(int p){
return power;
}
};
class comparison:private hero,private villan
{
public:
void power_comp(hero &h,villan &v)
{
if(h.get_power()>v.get_power())
{
cout<<"hero is stronger"<<endl;
return;
}
cout<<"villan is stronger"<<endl;
}
};
int main(){
hero CA;
villan skull;
CA.set_power(150);
skull.set_power(100);
comparison c;
c.pwer_comp(CA,skull);
}