有如下程序: #include using namespace std; class Point { public: static int number; public: Point() { number++; } ~Point() { number-

admin2021-06-10  10

问题 有如下程序:
#include
using namespace std;
class Point {
public:
static int number;
public:
Point() { number++; }
~Point() { number--; }
};
int Point::number=0;
int main() {
Point *ptr;
Point A, B;
{
Point* ptr_point=new Point[3];
ptr=ptr_point;
}
Point C;
cout<delete[] ptr;
return 0;
}
执行这个程序的输出结果是(     )。

选项 A、3
B、4
C、6
D、7

答案C

解析 本题考查默认构造函数,题目中定义一个对象A、B以及对象数组Point[3],又定义了对象C,共执行6次构造函数,number变为了6,所以本题答案为C。
转载请注明原文地址:https://kaotiyun.com/show/hufp777K
0

随机试题
最新回复(0)