In this tutorial, we will be discussing a program to understand pair in C++ Standard Template Library.
Pair is a container defined in the utility header that contains two values. It is used to combine two values and associate them even if they are of different types.
#include <iostream> #include <utility> using namespace std; int main(){ //initializing a pair pair <int, char> PAIR1 ; PAIR1.first = 100; PAIR1.second = 'G' ; cout << PAIR1.first << " " ; cout << PAIR1.second << endl ; return 0; }
100 G