华南俳烁实业有限公司

自考

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

排行熱點(diǎn)

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

全國(guó)2013年1月自學(xué)考試C++程序設(shè)計(jì)試題_第4頁(yè)

來源:考試網(wǎng) [ 2013年11月23日 ] 【大 中 小】

三、改錯(cuò)題(本大題共5小題,每小題2分,共10分)

下面的類定義中有一處錯(cuò)誤,請(qǐng)寫出錯(cuò)誤所在行并給出修改意見

41.#include<iostream.h>

     class point{

     private: float x,y;

public: point( float a,float b) { x = a;y = b; }

   void f( ) {x=0;y=0;}

     void getx( ) { cout<< x<< endl; }

void gety( ) { cout<< y<< endl; }

} ;

  main() {

 point a (3.5) ;

a.getx( )

}

42. #include < iostream. h >

   main( ) {

 int x =7;

   const int * p = &x;

* p=99

   cout<< * p<< endl;

}

43. #include < iostream. h >

   class test{

 private: int x;y;

 public: void f( int a,int b) { x = a;y = b; }

 int max( ) { return(x > y) ? x:y; }

} ;

 main( ) {

 test a;

 a.f(1,3);

 cout<< a. max( ) << endl;

}

44. #include < iostream. h >

   class test{

     private: int x;

     public:test( int a) { x = a; }

 void set( int a) { x = a; }

 void get( ) { cout<< x<< endl; }

} ;

   class testl: public test{

     private: int x;

 public : testl ( int a) { x = a; }

       void set( int a) { x = a; }

void get( ) { cout<< x<< endl; }

 } ;

45. #include < iostream. h >

   class f{

     private: int x,y;

     public:void fl ( int a,int b) { x = a;y = b ;}

void print( ){ cout<< x<< ''<< y<< endl; }

     } ;

   main( ) {

     f a;

 float x = 1.5 y = 2.0;

a.fl(x,y);

     a.print( );

     }

 

責(zé)編:may1205
璧山县| 磐安县| 柘荣县| 深泽县| 娄底市| 滨州市| 济源市| 南漳县| 芒康县| 丽江市| 连城县| 松滋市| 沐川县| 大埔区| 革吉县| 康平县| 满城县| 乐昌市| 汝州市| 临沂市| 孟连| 鄂尔多斯市| 绥德县| 合水县| 贵阳市| 文安县| 新干县| 怀安县| 襄樊市| 瑞丽市| 彩票| 万荣县| 蒙自县| 黄山市| 西充县| 大余县| 阜康市| 高青县| 秦皇岛市| 卫辉市| 普兰店市|