C++上机练习:改错与编程题.pdfVIP

  • 1
  • 0
  • 约1.97千字
  • 约 2页
  • 2026-03-19 发布于北京
  • 举报

一.改错题

1.下面程序是一个存在错误的程序,要求不增加或删除任何语句,使程序运行后的输出结

果为10+20-30。

#includeiostream.h

classExp{

intn;

public:

voidExp(inta){n=a;}

voidSet(inta){n=a;}

intGet(){returnn;}

};

voidmain(){

Expe1;

coute1.Get()+;

e1.n=20;

coute1.Get()-;

Exp.e2(30);

coute2.Get()\n;

}

2.下面是一个存在错误的程序,要求不增加或不删除任何语句,使程序能正常运行。

#includeiostream.h

#includestring.h

class{

intId;

char*Name;

public:

(inti,char*s){

文档评论(0)

1亿VIP精品文档

相关文档