Tsallaka zuwa abun ciki
Justice Tech School

pair and tuple

pair holds two values and tuple holds many.

Example
#include <iostream>
#include <tuple>
#include <utility>
#include <string>

int main() {
  std::pair<int, std::string> p{1, "a"};
  auto t = std::make_tuple(1, 2.5, "x");
  std::cout << p.first << p.second << " " << std::get<1>(t) << "\n";
  return 0;
}

Result

1a 2.5

Exercise

First of a pair.

p.

Quiz Test

How read a tuple item?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.