自考

各地资讯
当前位置:考试网 >> 自考 >> 自考真题 >> 工学类 >> C语言程序设计 >> 文章内容

排行热点

全国2009年10月自学考试C++程序设计试题_第4页

来源:考试网  [2008年12月29日]  【
三、改错题(本大题共5小题,每小题4分,共20分)
下面的每个程序都有一处错误,请用下横线标出错误所在行并给出修改意见。
41.#include
using namespace std;
int main ( ){
int num; max=10; num =1
while (num < max) num + + ;
cout <<″Num = ″<< num;
return 0;
}
42.#include
using namespace std;
class A {
void show ( ) {
cout<<″Hello!″;
}
};
int main ( ) {
A a;a. show ( );
return 0;
}
43.#include
using namespace std;
int main ( ) {
const int num = 20;
int scores[num];
for (int i=1;i<=num;i + +){
scores[i]=i;
}
return 0;
}
44.#include
using namespace std;
class CMax {
private:
int xx; int yy;
public:
CMax(int x,int y)
{ xx = x;yy = y ; }
void setValue(int x,int y)
{ xx = x;yy = y;}
int max( ){
return xx > yy? xx:yy;
}
};
void main( ){
CMax m( );
m.setValue(20,30);
cout <<″Max=″<}
45.#include
using namespace std;
class A{
public:
char name[255];
private:
char * getName( )
{ return name; }
};
class B:public A{
public:
B(char * n){
strcpy ( name,n);
}
};
void main( ){
B b(″Hello!″);
cout <<″Name:″<}

 

责编:admin

相关文章