Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须创建一个对象数组,但我的类中还有一个参数化构造函数,它对类的属性进行一些初始化。如何在 C++ 中做到这一点?
使用“正常”初始化列表?
例子:
struct S { S(int, const std::string&) {} // Just a dummy constructor }; S array_of_s[2] = { S(123, "foo"), S(456, "bar") };