Introduction to the example usage of pair method and vector method in C++
This article mainly explains "Introduction to the example usage of pair method and vector method in C++". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "Introduction to the example usage of pair method and vector method in C++" together.
The pair method.
Template struct pair
Parameters: T1 is the data type of the first value and T2 is the data type of the second value.
Function: pair combines a pair of values into a single value, which can have different data types (T1 and T2) and can be accessed by pair's two public functions, first and second.
Specific usage:
Access to two elements (via first and second):
pair p1; //Use default constructor p1.first = 1;p1.second = 2.5;cout