c ++ 20機能の1つである指定イニシャライザについて質問があります(この機能の詳細はこちら)
#include <iostream>
constexpr unsigned DEFAULT_SALARY {10000};
struct Person
{
    std::string name{};
    std::string surname{};
    unsigned age{};
};
struct Employee : Person
{
    unsigned salary{DEFAULT_SALARY};
};
int main()
{
    std::cout << std::boolalpha << std::is_aggregate_v<Person> << '\n'; // true is printed
    std::cout << std::boolalpha << std::is_aggregate_v<Employee> << '\n'; // true is printed
    Person p{.name{"John"}, .surname{"Wick"}, .age{40}}; // it's ok
    Employee e1{.name{"John"}, .surname{"Wick"}, .age{40}, .salary{50000}}; // doesn't compile, WHY ?
    // For e2 compiler prints a warning "missing initializer for member 'Employee::<anonymous>' [-Wmissing-field-initializers]"
    Employee e2 {.salary{55000}}; 
}
このコードはgcc 9.2.0と-Wall -Wextra -std=gnu++2aフラグを使用してコンパイルされています。
上記のように、両方の構造体PersonとEmployeeは集合体ですが、Employee指定された初期化子を使用して集合体を初期化することはできません。
なぜ誰かが私に理由を説明できますか?
public、private毎回使っているので、私はそれについて考えを無駄にしたことはありません...とにかくありがとう
                structsはデフォルトでパブリックに継承されます
                
struct Employee : public Person