当我运行此代码时:
struct X {
int a;
};
struct Y : public X {};
X x = {0};
Y Y = {0};
Run Code Online (Sandbox Code Playgroud)
我明白了:
error: could not convert ‘{0}’ from ‘<brace-enclosed initializer list>’ to ‘Y’
Run Code Online (Sandbox Code Playgroud)
为什么大括号初始化适用于基类而不适用于派生类?