2006年4月全国计算机等级考试二级C++语言程序设计笔试试卷

出处:www.examlink.com 作者:小罗 日期:2007年01月22日 16时08分

  (20)有如下程序:

  #include

  usingnamespacestd;

  intmain()

  {

  int*p;

  *p=9;

  cout<<"Thevalueatp:"<<*p;

  return0;

  }

  编译运行程序将出现的情况是

  A)够编译时出现语法错误,不能生成可执行文件

  B)运行时一定输出:Thevalueatp:9

  C)运行时一定输出:Thevalueatp:*9

  D)运行时有可能出错

  (21)有如下程序:

  #include

  usingnamespacestd;

  intmain()

  {

  voidfunction(doubleval);

  doubleval;

  function(val);

  cout<

  return0;

  }

  voidfunction(doubleval)

  {

  val=3;

  }

  编译运行这个程序将出现的情况是

  A)编译出错,无法运行B)输出:3

  C)输出:3。0D)输出一个不确定的数

  (22)有如下类定义:

  classAA

  {

  inta;

  public:

  intgetRef()const{return&a;}//①

  intgetValue()const{returna;}//②

  voidset(intn)const{a=n;}//③

  friendvoidshow(AAaa)const{cout<//④

  };

  其中的四个函数定义中正确的是

  A)①B)②C)③D)④

  (23)有如下程序:

  #include+

  usingnamespacestd;

  #include

  usingnamespacestd;

  classBase

  {

  public:

  voidfun(){cout<<"Base::fun"<

  };

  classDerived:publicBase

  {

  public:

  voidfun()

  {

  cout<<"Derived::fun"<

  }

  };

  intmain()

  {

  Derivedd;

  d。fun();

  return0;

  }

  已知其执行后的输出结果为:

  Base::fun

  Derived::fun

  则程序中下划线处应填入的语句是

  A)Base。fun();B)Base::fun()C)Base->fun()D)fun();

  

最后更新时间:2008-05-28 11:40:20
文章评论
共有 0 位网友发表了评论
用户名: 新注册) 密码: 匿名评论 [查看所有评论]

评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
您可以用以下几种方式找到此文章

考试全流程