1// make_pair example
2#include <utility> // std::pair
3#include <iostream> // std::cout
4
5int main () {
6 std::pair <int,int> foo;
7 std::pair <int,int> bar;
8
9 foo = std::make_pair (10,20);
10 bar = std::make_pair (10.5,'A'); // ok: implicit conversion from pair<double,char>
11
12 std::cout << "foo: " << foo.first << ", " << foo.second << '\n';
13 std::cout << "bar: " << bar.first << ", " << bar.second << '\n';
14
15 return 0;
16}
1// CPP program to illustrate pair STL
2#include <iostream>
3#include <utility>
4using namespace std;
5
6int main()
7{
8 pair<int, char> PAIR1;
9
10 PAIR1.first = 100;
11 PAIR1.second = 'G';
12
13 cout << PAIR1.first << " ";
14 cout << PAIR1.second << endl;
15
16 return 0;
17}
18