A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-126.cpp
1#include<iostream>
2structCents{
3intv;
4explicitCents(intn):v(n){}
5};
6intmain(){
7Centsc=Cents(7);
8std::cout<<c.v<<"\n";
9return0;
10}
Conversions
Answer & explanation
Console output
7
Why
The explicit keyword forbids implicit conversions (like Cents c = 7;) but an explicit, spelled-out construction such as Cents(7) is still perfectly legal. The copy-initialization from an explicit temporary works because the conversion is requested directly, so c.v holds 7.