(21)关于友元的概念错误的是
A)友元函数没有this指针
B)调用友元函数时必须在它的实参中给出要访问的对象
C)一个类的成员函数也可以作为另一个类的友元函数
D)只能在类的公有段声明友元
(22)关于抽象类下面说法正确的是
A)抽象类就是其中有函数定义但没有实现的类
B)抽象类是可以被实例化的
C)派生类不能成为抽象类
D)抽象类的子类必须实现父类中的纯虚函数
(23)下面程序的结果是
#include class test { private: int num; public: test(); int getint(){return num;} ~test();}; test :: test() { num =0;} test::~test() { cout<<"Destructor is active"< { test x[3]; cout<<"Exiting main"< Destructor is active Destructor is active Destructor is active B)Exiting main Destructor is active Destructor is active C)Exiting main Destructor is active D)Exiting main (24)如果表达式--x+y中,--是作为成员函数重载的, +是作为成员函数重载的,则该表达式还可为 A)y.operator+(x.operator--(0)) B)y.operator+(x.operator--()) C)y.operator+(operator--(x,0)) D)operator+(x.operator--()) (25)下列语句不能够用于打开C根目录下文件test.txt的语句是 A)ifstream fin; fin.open("C:\\test.txt"); B)ifstream fin("C:\\test.txt"); C)A)和B) D)ifstream fin; fin("C:\\test.txt"); (26)以下哪个基类中的成员函数表示纯虚函数? A)virtual void vf (int) B)void vf (int)=0 C)virtual void vf(=0) D)virtual void yf(int){ } (27)下面程序输出的结果是 #include void main() { int i; int a[3][3]={1,2,3,4,5,6,7,8,9}; for(i=0;i<3;i++) cout << a[i][i] << " ";} A)1 5 9 B)7 5 3 C)3 5 7 D)5 9 1 (28)派生类继承基类的方式有 A)public B)private C)protected D)以上都对 (29)下列程序的运行结果为 #include class Location { protected: int X, Y; public: void SetX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy(){cout << "X=" << X << " " << "Y=" << Y < private: int H, W; public: void SetH(int myh){H=myh;} void SetW(int myw){W=myw;} void show(){ cout << "X=" << X << " " << "Y=" << " " << Y << " " << "H=" << H << " " << "W=" << W << endl;}}; void main() { Rectangle r1; r1.SetX (3); r1.SetY (5); r1.SetH (4); r1.SetW (6); r1.showxy(); r1.show();} A)X=3 Y=5 X=3 Y=5 H=4 W=6 B)X=3 Y=5 X=3 Y=5 H=3 W=6 C)X=3 Y=5 X=3 Y=4 H=4 W=6 D)X=3 Y=5 X=3 Y=3 H=4 W=6 (30)有以下程序 #include void ss(char *s,char t) { while(*s) { if(*s==t)*s=t-′a′+′A′; s++;}} void main() { char str1[100]="abcddfefdbd",c=′d′; ss(str1,c); cout << str1;} 程序运行后的输出结果是 A)ABCDDEFEDBD B)abcDDfefDbD C)abcAAfefAbA D)Abcddfefdbd
① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;
② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。