单选题 C++
题号 #2606893

有如下程序:
#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。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考