Having Fun With C++ [Quiz Series- Part 1]

Quiz Series- Part 1

Table of Content

Joseph Sibony

reading time: 

1–2 minutes

While C++ is always fun (except for C++ build times, of course), there are moments where we really get to have a blast. For me, the following C++ quiz is one of these moments. I’m not sure what did it for me. Was it the thrill of solving a challenge, or just the chance to play around with the language like a kid.

I hope you’ll have as much fun as I had.

Thanks to Anders Schau Knatten from CppQuiz for creating this quiz!

The Quiz!

#include <iostream>

template<class T>

void f(T) { std::cout << 1; }

template<>

void f<>(int*) { std::cout << 2; }

template<class T>

void f(T*) { std::cout << 3; }

int main() {

    int *p = nullptr; 

    f( p );

}

Hint:

Before I spoil everything and reveal the answer,  here’s a nice hint for you:

A declaration of a function template being explicitly specialized shall precede the declaration of the explicit specialization. During overload resolution, only the base function templates are considered, not specializations.

Know the answer?

Send it to us at [email protected]. The winners will be announced on our social pages.

speed up c++

Shorten your builds

Incredibuild empowers your teams to be productive and focus on innovating.

Table of Content

Shorten Your Builds

Incredibuild empowers your teams to be productive and focus on innovating.

Share

Related Blog Posts

C++, Compilers, Financial Services, MedTech
Why we built Islo:  AI coding agents need an execution layer
[4 May 2026]
C++, Compilers, Financial Services, MedTech
The SBOM challenge: achieving zero false positives
[16 Apr 2026]
C++
The illusion of control: is your SBOM lying to you?
[23 Mar 2026]

Never run anything twice

AI SANDBOX NEW
ISLO: The always-on execution layer for AI coding agents
PRODUCT · RELEASED MAY 2026
LEARN MORE
AI-NATIVE DEVELOPMENT NEW
Why AI coding agents need an execution layer
BLOG · PUBLISHED MAY 2026
READ MORE
CI ACCELERATION BETA
Run GitHub Actions faster With Build Runners
PRODUCT · JOIN THE BETA
LEARN MORE