The pair type is defined in the utility header file, contains two data values, and the members of the pair class are public, and the two members are named First and second respectively. You can access its data members directly in P.first or P.second way, when creating a pair object, You must provide two type names: The pair object contains two data members corresponding to the type name, and these two types do not have to be the same.
Pair<t1, t2> p1; Creates an empty pair object, which is the T1 and T2 types, with value initialization, such as
Pair<string, string> A;
Pair<string, int>b;
Pair<string, vector<int> > C;
Pair<t1, t2> p1 (v1, v2); Create a pair object, the first member is initialized to V1, and the second member is initialized to V2, as
Pair<string, string> D ("Xixi", "haha");
Make_pair (v1, v2); Creates a new pair object with the values of V1 and V2, whose element types are the types V1 and V2, respectively, as
Pair<int, int> test;
Test= Make_pair ();
The effect is equivalent to Pair<int, int> test;
C + + pair type