I've this this kind of code used in some source, so I tried it and it works:
struct B {
int x, y;
B (int _x, int _y): x(_x), y(_y) {}
};
struct A {
B b;
A (B _b): b(_b) {}
};
int main()
{
A a {{3, 4}};
return 0;
}
Can anyone explain how is this "implicit instance" constructed and point me to where it is documented? If I got it correctly, A a {{3, 4}}; is a shortcut for A a2 {B{3, 4}};. Is this correct?
How can the compiler understand that I'm trying to get a new implicit instance of B if, for example, I overload the constructor so that it accepts another class that can be constructed with two ints?
Thanks