【发布时间】:2018-04-23 08:12:04
【问题描述】:
我有一个类hi,它带有一个带两个参数的非默认构造函数。我正在尝试构造his 的数组:
class hi {
public:
hi(int a, int b){};
};
int main() {
hi *hello;
int number_of instance = 5;
hello = new hi[number_of_instance]; // (1)
}
如何在标有(1)的行上调用hi::hi(int,int)?
【问题讨论】:
-
hello = new hi[5]{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}};
标签: c++ arrays pointers constructor