1

Pair in C++ STL

 1 year ago
source link: https://www.geeksforgeeks.org/videos/pair-in-c-stl/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Pair in C++ STL

Pair in C++ STL
Hi and welcome to Geeks. Geeks
Loaded: 2.03%
Remaining Time -2:28
  • 11/05/2022

Pair is used to combine together two values that may be different in type. Pair provides a way to store two heterogeneous objects as a single unit. It is basically used if we want to store tuples. The pair container is a simple container defined in <utility> header consisting of two data elements or objects.

The first element is referenced as ‘first’ and the second element as ‘second’ and the order is fixed (first, second).

Pair can be assigned, copied, and compared. The array of objects allocated in a map or hash_map is of type ‘pair’ by default in which all the ‘first’ elements are unique keys associated with their ‘second’ value objects.

To access the elements, we use variable name followed by dot operator followed by the keyword first or second.

Syntax:

pair (data_type1, data_type2) Pair_name

Pair in C++ STL:https://www.geeksforgeeks.org/pair-in-cpp-stl/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK