单项选择题
有如下程序: #include <iostream.h> using namespace std; class Demo { public: Demo(){ cout<<"defautt constmctor\n"; } Demo(const Demo &x){cont<<"copy constmctor\n";} }; Demo userCode (Demo b){Demo c(b);return c;} int main() { Demo a,d; cout<<"calling userCode()\n"; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo&x)被调用的次数分别是( )。
A.1和1
B.1和2
C.2和3
D.2和4
点击查看答案
<上一题
目录
下一题>
热门
试题
单项选择题
以下程序的执行结果为( )。 #include <iostream.h> class Sample { int n; public: Sample(int i) {n=i;} operator++() {n++;} 前缀重载运算符 operator++(int) {n+=2;} 后缀重载运算符 void disp() { cout<< n= <<n<<endl; } }; void main() { Sample A(2),B(2); A++; ++B; A.disp(); A.disp(); }
A.n=4
B.n=1
C.n=3
D.n=5 n=3 n=2 n=4 n=6
点击查看答案
单项选择题
若有函数fun(x,y),并且已经使函数指针变量p指向函数fun,则使用p调用函数fun的正确方法是( )。
A.(*fun(x,;
B.*pfun(x,;
C.(*(x,
D.*p(x,
点击查看答案
相关试题
阅读下面程序:#include <iostream.h>...
下面程序的运行结果是 【13】 。#incl...
有如下类声明:class MyClass{int i;pr...
语句cout<<setiosflagags(ios::showpo...
已知下列程序的输出结果是42,请将画线处...