华南俳烁实业有限公司

自考

各地資訊
當(dāng)前位置:考試網(wǎng) >> 自學(xué)考試 >> 自考真題 >> 工學(xué)類 >> C語言程序設(shè)計 >> 文章內(nèi)容

排行熱點(diǎn)

  • 歷年真題
  • 模擬試題
  • 自考自答

全國2011年10月高等教育自學(xué)考試C++程序設(shè)計試題_第4頁

來源:考試網(wǎng) [ 2011年12月10日 ] 【大 中 小】
三、改錯題(本大題共5小題,每小題4分,共20分)
下面的每題中有一處錯誤,請用下橫線標(biāo)出錯誤所在行并給出修改意見
41. #include < iostream. h >
void main( ){
float * p;
p = new float[ 5 ] ;
for( i =0;i <5 ;i + + )
{ cin > > * (p + i) ;cout << * (p + i) << endl; }
delete [ ] p;
}
42. #include < iostream.h >
template < class T >
class f{
private: T x,y;
public: void fl(T a,T b){x=a;y=b;}
T max(){retum(x>y)? x:y;}
};
void main( ){
f <int> a;
a. fl(3.5,3.8) ;
cout << a. max( ) << endl;
}
43. #include < iostream. h >
class test{
private: static int x; int y;
public: void testl ( int a, int b) { x = a; y = b; }
};
void main() {
test a;
a. testl (2,3) ;
}
44. #include < iostream, h >
class f{
private: float x, y;
public: void fl ( float a, float b) { x = a; y = b; }
f() {x=0;y=0;}
void move(float a,float b){x =x +a;y =y-b;}
void get ( ) { cout << x <<"<< y << endl; }
};
void main( ){
f *p,a;
a. f1(1.6,3.8) ;
p=&a;
p. get( ) ;
}
45. #include < iostream. h >
class point{
int x;
public: void init ( int a) { x = a; }
int getx( ){ return x;}
void setx ( int a) { x = a; }
};
void main( ){
point a;
a. init (20,30) ;
cout << a. getx( ) << endl;
}
責(zé)編:snrvge
时尚| 凤城市| 和平区| 南安市| 甘泉县| 灌南县| 金门县| 安吉县| 霍城县| 金昌市| 乐山市| 淮阳县| 柳林县| 堆龙德庆县| 南丹县| 顺昌县| 定州市| 玉田县| 柞水县| 东宁县| 绵阳市| 武威市| 米脂县| 石泉县| 张家川| 苍南县| 穆棱市| 龙泉市| 东辽县| 洱源县| 民权县| 永吉县| 汾阳市| 潞西市| 筠连县| 万州区| 南丰县| 营山县| 五大连池市| 涿鹿县| 清丰县|