Answers for "pairs in c++"

C++
9

pair c++

// make_pair example
#include <utility>      // std::pair
#include <iostream>     // std::cout

int main () {
  std::pair <int,int> foo;
  std::pair <int,int> bar;

  foo = std::make_pair (10,20);
  bar = std::make_pair (10.5,'A'); // ok: implicit conversion from pair<double,char>

  std::cout << "foo: " << foo.first << ", " << foo.second << '\n';
  std::cout << "bar: " << bar.first << ", " << bar.second << '\n';

  return 0;
}
Posted by: Guest on May-14-2020
0

pairs in c++

pair (data_type1, data_type2) Pair_name
Posted by: Guest on September-08-2021

Browse Popular Code Answers by Language