C/C++ Arena

Step 5 of 6

pair and tuple

std::pair<A, B> holds two values (.first, .second). std::tuple holds any number. Structured bindings unpack both:

std::pair<std::string, int> best = {"ropz", 25};
auto [name, kills] = best;

std::tuple<int, int, int> kda = {20, 5, 14};
auto [k, a, d] = kda;

Your turn: fill in the blanks.

Previous: unordered_map Next: Challenge: balanced brackets