A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-114.cpp
1#include<iostream>
2structWrap{
3intv;
4Wrap(intn):v(n+1){}
5};
6intmain(){
7Wrapw=10;
8std::cout<<w.v<<"\n";
9return0;
10}
Conversions
Answer & explanation
Console output
11
Why
Wrap w = 10; is copy-initialization that implicitly invokes the non-explicit Wrap(int) constructor with 10. The constructor body computes v = n + 1, so w.v becomes 11. The implicit conversion is allowed precisely because the constructor is not marked explicit.