-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClasses-and-objects.cpp
More file actions
49 lines (39 loc) · 1.1 KB
/
Classes-and-objects.cpp
File metadata and controls
49 lines (39 loc) · 1.1 KB
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>
#include<string>
#include<vector>
using namespace std;
class Player
{
public:
string name;
int health;
int xp;
void talk(string text_to_say)
{
cout << name << " says " << text_to_say << endl;
}
};
int main()
{
Player Player1;
Player Player2;
Player1.name = "RohitRaider";
Player1.health = 100;
Player1.xp = 34;
cout << "========================================" << endl;
cout << "The Name of player is: " << Player1.name << endl;
cout << "The Health of player is: " << Player1.health << endl;
cout << "The XP of player is: " << Player1.xp << endl;
Player1.talk("I'll Kill You!!");
cout << "========================================" << endl;
Player* enemy = new Player;
(*enemy).name = "Anshuman";
enemy->health = 100;
enemy->xp = 50;
cout << "========================================" << endl;
cout << "The Name of enemy is: " << (*enemy).name << endl;
cout << "The Health of enemy is: " << enemy->health << endl;
cout << "The XP of enemy is: " << enemy->xp << endl;
enemy->talk("Daddy's Home Boy!!");
cout << "========================================" << endl;
}