-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmax_elementSTL.cpp
70 lines (59 loc) · 1.38 KB
/
max_elementSTL.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
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;
class User {
public:
User();
User(string name, int id, int date_birthday, string work);
string GetName() const;
int GetId() const;
int GetDateBirthday() const;
string GetWork() const;
private:
string name_;
string work_;
int id_;
int date_birthday_;
};
User::User()
{
}
User::User(string name, int id, int date_birthday, string work) :
name_(name), id_(id), date_birthday_(date_birthday), work_(work)
{
}
string User::GetName() const
{
return name_;
}
int User::GetId() const
{
return id_;
}
int User::GetDateBirthday() const
{
return date_birthday_;
}
string User::GetWork() const
{
return work_;
}
ostream& operator<< (ostream& os, User& user) {
os << user.GetName() << " " << user.GetId() << " " << user.GetDateBirthday();
return os;
}
int main() {
User Sergey("Sergey", 43, 1998, "Simple code");
User Vlad("Vlad", 23, 2004, "Print dick");
User Temirlan("Rerror", 12, 2003, "Wed fuck");
User Chehov("Chehov", 432, 2005, "Fuck Brains");
vector <User> user{ Sergey, Vlad, Temirlan, Chehov };
list <User> user_l{ Sergey, Vlad, Temirlan, Chehov };
auto result = max_element(user.begin(), user.end(), [](const User &u1, const User& u2) {
return u1.GetId() < u2.GetId();
});
cout << *result << endl;
return 0;
}