Pair - C P P

Theory


  • Pair class couples together the pair of values, which may be of different types (T1 and T2)

Commands


  • pair<dataType1, dataType2> variable; => Initialize
    • pair<dataType1, pair<dataType2, dataType3>> variable; => Nested pair Initialization
  • pair<dataType, dataType> variable(N1, N2); => Initialize a pair with first and second values
  • variable = make_pair(N1, N2); => Make a pair with first and second values
    • variable = {N1, N2}; => Declare the values of pair with first and second values
  • variable.first => Gives first value of pair
  • variable.second => Gives second value of pair
Share: