自定义类的数组,会根据数组元素的个数调用构造函数和析构函数;
自定义类的指针数组,不会调用构造函数和析构函数;
自定义类的指针,同样不会调用构造函数和析构函数,例如:
class test {
public:
test() {
cout << "构造函数" << endl;
}
~test() {
cout << "析构函数" << endl;
}
};
test a[2]; 调用两次构造函数和析构函数
test *b[2]; 不调用构造函数和析构函数
test *c; 不调用构造函数和析构函数