问题
单项选择题
有如下程序:
#include <iostream>
using namespace std;
class test
private:
int a;
public:
test( )cout<<"constructor"<<endl;
test(int A) cout<<a<<endl;
test(const test &_test)
a=_test.a;
cout<<"copy constructor"<<endl;
~test()cout<<"destructor"<<endl;
;
int main( )
test A(3)
return 0;
程序的输出结果是
A) 3
destructor
B) constructor
destructor
C) copy constructor
destructor
D) 3
答案
参考答案:A
解析: test的构造函数重载,test A[3]调用test(int A) 函数,然后删除时调用析构函数,故输出选项A。