如何在 C++03 中从初始化列表中初始化数组成员?

问题描述 投票:0回答:0

以下在 C++11 中工作正常,但在 C++03 中不起作用。

struct Foo {
    int a, b;
    Foo(int a, int b) : a(a), b(b) {}
};

struct Bar {
    Foo foos[2];
    Bar() :
        foos{ {1,2}, {2,3} },
    {}
};

int main() {}

C++03 的解决方法是什么?

c++ initializer-list c++03
© www.soinside.com 2019 - 2024. All rights reserved.