-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop.cpp
191 lines (94 loc) · 2.57 KB
/
oop.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>/*
#include <ctime>
#include <cstdio>
#include <iostrexam>
#include <vector>
#include <string>
#include <iomanip> //setprecision function
#include <cmath> //math
#include <cstdio>
#include <vector> //vector array
#include <algorithm> //STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream
#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging printing variable
with name*/
using namespace std;
int y=5;
//c++ templte for help...........................................................
#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging printing variable
with name*/
// for printing value of variable with cout
template<typename... T>
void print(T... t){
((cout<<t<<" "),...);
}
//for saving as stringstream
template<typename... T>
string ss(T... t){
stringstream sis;
((sis<<t<<" "),...);
return sis.str();
}
//for taking multiple input
template<typename... T>
void input(T&... t){
((cin>>t),...);
}
//for loop
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
//to print vector element
template<typename T>
void printV(T vec){
int i;
fo(i,vec.size()) print(vec[i]);
}
//c++ template for help........................................................
class player{
public:
string name;
int health;
player(string name="none",int a=0);
player();
bool operator==(const player rhs);
};
bool player::operator==(const player rhs){
if(this->name==rhs.name)
return true;
else return false;
}
player::player(string name,int health):name{name},health{health}{
}
int main(){
print(setprecision(16));
//player frank{"frank",0};
//player newplayer{"",0};//copy constructor
//newplayer=frank;/*deep copy*/
//frank.name="madarchod";
//cout<<newplayer.name<<" "<<frank.name<<endl;
//player *frank=new player{"frank",0};
//player *newplayer=new player{"",0};
//newplayer=frank;//shallow copy
//cout<<newplayer->name<<" "<<frank->name<<endl;
player akhil{"n",0};
player nikhil{"akhil",2};
player nikhil1{"akhil",2};
if(akhil==nikhil) cout<<"true"<<endl;
//both r same
if(akhil.operator==(nikhil)) cout<<"true"<<endl;
vector<player> team{akhil,nikhil};
auto loc=find(team.begin(),team.end(),nikhil1);
cout<<loc->health<<endl;
return 0;
}