Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C++ Language/Std/Stl/CollectionClasses/SortedCollections/PairAsOneItem

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

A "pair" is an object whose type encapsulates two other types. A pair has a literal form, using braces: std::pair<char,int> ciVar = {'a',11};. Access each component as ciVar.first or ciVar.second. Pair assignment (= operator) copies-by-value the two elements from source to destination. Usually, assignment's destination is another pair. However, pair-assignment could also use std::tie() to decompose into two scalar variables. Additional information about std::pair (includes interactive examples)