设为首页 加入收藏

TOP

2013年全国计算机等级二级考试C++考前试题及答案解析三
2014-11-08 13:00:06 】 浏览:626
Tags:2013年全国 计算机 等级 二级 考试 考前 试题 答案 解析

  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"< P>


  { 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)Abcddfefdb


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2013年全国计算机等级二级考试C++.. 下一篇2013年全国计算机等级二级考试C++..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目