首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #inclube <iostream.h> class ClassOne { public: ClassOne(int v=O) { i=v;cout<<i;} void print(){ co
有以下程序 #inclube <iostream.h> class ClassOne { public: ClassOne(int v=O) { i=v;cout<<i;} void print(){ co
admin
2010-03-29
70
问题
有以下程序 #inclube <iostream.h> class ClassOne { public: ClassOne(int v=O) { i=v;cout<<i;} void print(){ cout<<i<<end1;} }; class ClassTwo { public: ClassTwo(int v=O) { i=v;cout<<i;} void print(){ cout<<i<<end1;} private: ClassOne myObj; int i; }; void main() { ClassTwo obj(1); obj.print(); }
选项
A、11
B、111
C、110
D、101
答案
1
解析
类ClassTwo中定义了成员对象myObj,所以在构造类ClassTwo的对象obj时会先调用类ClassOne的构造函数输出0,然后调用ClassTwo的构造函数输出 1。主函数最后调用obj的成员函数print()输出1。所以最后结果为011。
转载请注明原文地址:https://kaotiyun.com/show/OGjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下叙述中正确的是
设floata[10],*s=a;以下能够代表数组元素a[3]的是()。
有以下程序:#include<stdioh>main(){imy=9;for(;y>0;y--)if(y%3==0)printf(’’%d’’,-y);}程序的运
若有以下函数首部intfun(doublex[10],intn)则下面针对此函数的函数声明语句中正确的是
下面对软件测试描述错误的是()。
有以下函数:intfun(char*x,char*y){intn=0;while((*x==*y)&&*x!=’\0’){x++;y++;n++:}returnn:}函数的功能是()。
在快速排序法中,每经过一次数据交换(或移动)后
函数ftell(fp)的作用是()。
下列排序方法中,最坏情况下比较次数最少的是()。
设序列长度为n,在最坏情况下,时间复杂度为0(log2n)的算法是()。
随机试题
试述汽车维修价格的影响因素。
下列不属于锚具辅助性试验项目的是()。
根据代理法律制度的规定,下列行为中,不属于代理的有()。
Howlongcanhumanbeingslive?Mostscientistswhostudyoldagethinkthatthehumanbodyis【C1】________tolivenolongerthan
导语(中国传媒大学2012年MJC真题)
我国是谁最早发现了甲骨文?()
《中华人民共和国反分裂国家法》规定“对台动武的前提条件”有()
求下列极限:(a1>0,a2>0)
微分方程(2x+3)y’’=4y’的通解为_________.
Somethingkeptscratchingontheoutsideofthetent.Iwouldn’thavethoughtmuchaboutit【C1】______Ihadn’trecentlyseenari
最新回复
(
0
)