Just an instructive interview question: "What does this C++14 program print?"
#include <iostream>
struct A { int i; };
struct B {
A a{1};
operator int() { return a.i; }
};
int main() {
B x({});
B y{{}};
std::cout << x << y;
}
And it actually prints 10
, meaning that the braces in the definition of y
change its initial value. But how?