← Back to archive

Stdle #172 · overload · 2026-11-25

What does this C++ snippet output?

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

#include <iostream>
template <typename T> void f(T) { std::cout << "T\n"; }
template <typename T> void f(T*) { std::cout << "T*\n"; }
int main() {
int x = 0;
f(x);
f(&x);
}
Overload
2 lines
4 attempts left

Answer & explanation