STD :: Pair in C++ STL with Examples

STD :: Pair in C++ STL

1. Pair is a template class in Standard Template Library (STL) in C++.

2. It is not a part of a container.

3. It is defined in <utility> header.

4. It consists of two data elements or objects.

5. The first element is referenced as 'first'.

6. The second element is referenced as 'second'.

7. The order of first and second element is fixed i.e., (firstsecond).

8. Pair is used to combined together two values which may be different in type.

9. Pair provides a way to store two heterogeneous objects as a single unit.

10. Pair can be assignedcopied and compared.

11. We use variable name followed by the dot operator followed by the keyword first or second to access the elements in pair.

Newest
Previous
Next Post »