招生考试网
学历类| 阳光高考 研 究 生 自学考试 成人高考 专 升 本 中考会考 外语类| 四 六 级 职称英语 商务英语 公共英语 日语能力
资格类| 公 务 员 报 关 员 银行从业 司法考试 导 游 证 教师资格 财会类| 会 计 证 经 济 师 会计职称 注册会计 税 务 师
工程类| 一级建造 二级建造 造 价 师 造 价 员 咨 询 师 监 理 师 医学类| 卫生资格 执业医师 执业药师 执业护士 国际护士
计算机| 等级考试 软件水平 应用能力 其它类| 书画等级 美国高考 驾 驶 员 书法等级 少儿英语 报 检 员 单 证 员 出国留学
 招生考试网 - 自学考试 - 自考真题 - 正文
2011年自考C++程序设计试题
来源:fjzsksw.com 2011-6-8 16:31:24 【字体:小 大】

 

二、排除下列程序的错误(每处错误3分,共30分)

1、请指出以下程序的3处错误的位置

#include

void f1();

void f2(int x);

void f2(int x,int y=0);

void f2(const int&);

void main()

{

f1();

       f2(3,4);

       f2(3);

}

void f1(int x)

{

       cout<

}

void f2(int x)

{

       cout<

}

void f2(int x,int y)

{

cout<

}

void f2(const int & x)

{

       cout<

}

2、请指出以下程序的4处错误的位置

#include

class sample

{

public:

       sample (int xx, int zz)

{

x=xx;

z=zz;

}

       void disp(){cout<

       static void f1()

{

              cout<

       }

       void ~sample()

       {cout<<”destructing object”<

protected:

       int x;

       static int y=100;

       const z;

};

void main()

{

       const sample a2(3, 5);

       a2.disp();

}

3、请指出以下程序的3处错误的位置

#include

class base

{

protected:

       int x;

       int *p;

public:

       base(int xx)

       {

              x=xx;

              p=new int[x];

       }

       ~base()

       {delete []p;}

};

class derive:public base

{

protected:

       int y;

       int * p1;

public:

       derive(int xx,int yy)

       {

              p=new int[x=xx];

       y=yy;

       p1=new int[yy];

}

~derive()

{

       delete []p1;

}

};

void main()

{

       base b1[10];

base *p1;

       derive *p2;

       p2=new derive(10,10);

       p1=p2;

       free p1;

}

 

网站版权与免责声明
①由于各方面情况的不断调整与变化,本网所提供的相关信息请以权威部门公布的正式信息为准.
②本网转载的文/图等稿件出于非商业性目的,如转载稿涉及版权等问题,请在两周内来电联系.