← Back to archive

Stdle #117 · classes · 2026-10-01

What does this C++ snippet output?

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

#include <iostream>
#include <vector>
void zero(std::vector<int> v) {
for (auto& e : v) e = 0; // mutates the copy
}
int main() {
std::vector<int> d = {7, 8, 9};
zero(d);
std::cout << d[0] << d[1] << d[2] << "\n";
return 0;
}
Classes
4 attempts left

Answer & explanation