← Back to archive

Stdle #95 · containers · 2026-09-09

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
#include <vector>
int main() {
std::vector<int> a = {1, 2}, b = {3, 4};
a.swap(b);
std::cout << a[0] << " " << b[0] << "\n";
}
Containers
4 attempts left

Answer & explanation