-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOOP1_ClassObject.cpp
68 lines (52 loc) · 992 Bytes
/
OOP1_ClassObject.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
62
63
64
65
66
67
68
/*
Author: Raghu
This is learnig content
Free to download and use
*/
#include <iostream>
#include <string>
using namespace std;
class Player
{
public:
//Constructor
Player()
{
Name = "Ronaldo";
Age = 39;
Health = 101.f;
}
string Name;
int Age;
float Health;
//Function inside the Class
void Run()
{
cout << "Player: '" << Name << "' is Running Now ...." << endl;
}
void GameStart();
};
//Function Outside the Class
void Player::GameStart()
{
cout << "Player: '" << Player::Name << "' Game Loading ...." << endl;
}
int main()
{
system("cls");
//Player - 1
Player PL_Raghu;
PL_Raghu.Name = "Raghu";
PL_Raghu.Age = 40;
PL_Raghu.Health = 50.0f;
PL_Raghu.Run();
PL_Raghu.GameStart();
//Player -2 Object is created with Class
Player PL_Shaivi;
PL_Shaivi.Name = "Jaya";
PL_Shaivi.Age = 35;
PL_Shaivi.Health = 20.5f;
PL_Shaivi.Run();
PL_Shaivi.GameStart();
system("pause");
}