单选题 有如下程序:
#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;
}
执行这个程序的输出结果是______。
【正确答案】 D
【答案解析】[解析] 本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destructor。所以本题答案为D。