#include // header containing pair and various other STL primitives #include #include using namespace std; typedef pair isp; // typedef is useful in creating abbreviations for template instantiations void main() { isp p(0,"Demonstrating use of the pair template"); cout << "The integer: " << p.first << endl // print first element of p, i.e. the int value << "The string:" << p.second << endl; // print second element of p, i.e. the string value isp::first_type i_val; // declare new variable with same type as first element of i_s_pair isp::second_type s_val; // declare new variable with same type as second element of i_s_pair cout << "Input new int and string for first pair:" << endl; cin >> i_val >> s_val; p = make_pair(i_val,s_val); // create new pair using helper function make_pair(first,second) cout << "Input new int and string for second pair:" << endl; cin >> i_val >> s_val; isp p2(i_val, s_val); if (p < p2) // true if (p.first < p2.first) OR (p.first == p2.first AND p.second < p2.second), false otherwise { cout << "p is less than p2" << endl; } else { cout << "p2 is less than p" << endl; } }