forked from nattee/data2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_overload.cpp
39 lines (29 loc) · 1.04 KB
/
main_overload.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
#include <iostream>
#include <vector>
#include <algorithm>
#include "pair.h"
using namespace std;
int main() {
CP::pair<int,std::string> a(10,"vishnu");
CP::pair<int,std::string> b(a);
cout << endl << "using equality operator" << endl;
cout << "a == b? " << (a == b ? "YES" : "NO") << endl;
CP::pair<int,std::string> c(999,"asdf");
cout << endl << "using assignment operator" << endl;
c = a;
cout << "a == c? " << (a == c ? "YES" : "NO") << endl;
c.second = "abc";
cout << "a == c? " << (a == c ? "YES" : "NO") << endl;
cout << endl << "using comparison operator" << endl;
std::vector<CP::pair<int,string> > v;
v.push_back( CP::pair<int,string>(10,"asdf"));
v.push_back( CP::pair<int,string>(10,"ddd"));
v.push_back( CP::pair<int,string>(5,"asdf"));
v.push_back( CP::pair<int,string>(3,"X"));
v.push_back( CP::pair<int,string>(1,"asdf"));
v.push_back( CP::pair<int,string>(10,"zzz"));
sort(v.begin(),v.end());
for (size_t i = 0;i < v.size();i++) {
cout << v[i].first << " " << v[i].second << endl;
}
}