// This program demonstrates the templated pair class // and the templated make_pair utility function. #include // for pair and make_pair #include using namespace std; int main() { pair p(11, 22.33); cout << p.first << ", " << p.second << '\n'; // Assign values the hard way: p.first = 44; p.second = 55.66; cout << p.first << ", " << p.second << '\n'; // Assign values using make_pair: p = make_pair(77, 88.99); cout << p.first << ", " << p.second << '\n'; // Since C++11, we can just use braced assignment. // It creates a temporary pair and copies (moves, really) it. p = {42, 67.89}; cout << p.first << ", " << p.second << '\n'; return 0; }