我们有如下类:A16
#include <iostream>
#include <unistd.h>
using namespace std;
class A16 {
public:
explicit A16(int index, int width) {
cout << "second constructor: index" << "=" << index << ",width="
<< width << endl;
}
int say() {
cout << "A say" << endl;
return 0;
}
virtual ~A16() {
cout << "destructor called" << endl;
}
};
创建一个A16对象的数组:
静态创建
A16 b[]= { A16(1, 2), A16(3, 4), A16(5, 6) };
或者动态创建:
A16 *b = new A16[] { A16(1, 2), A16(3, 4), A16(5, 6) };
或者
A16 *b = new A16[] { A 16{1, 2}, A 16{3, 4}, A16 {5, 6} };