华南俳烁实业有限公司

自考

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

排行熱點(diǎn)

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

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

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

四、完成程序題(本大題共5小題,每題4分,共20分)

46.將下劃線處缺少的部分寫(xiě)在“答題紙”上。源程序如下:

   #include < iostream >

   using namespace std ;

class base

   {

     int a,b;

 public:

     base(int x,int y){a=x;b=y;}

     void show(________________)

     {

 cout<<p.a<<’’,’’<<p.b<<endl;

     }

   }________________

 void main( )

   {

     base b(78,87);

b.show(b);

   }

47.將下劃線處缺少的部分寫(xiě)在“答題紙’’上。源程序如下:

 #include <iostream>

    #include <fstream>

    using namespace std ;

    void main( )

    {

        ________________myf(''ab. txt'');//定義輸出流文件,并初始化

        ________________<<''This ia a TXT file'';//向文件輸入字符串

     myf. close( );

    }

48.在下面程序中的下劃線處填上適當(dāng)?shù)某绦颍ù鸢笇?xiě)在“答題紙’’上),使程序的輸出

結(jié)果如下:

 67,90

 源程序如下:

 #include <iostream>

   using namespace std ;

   class base

   {

   private:

     int x,y;

   public:

     void initxy( int a,int b){x=a;y=b;}

     void show( base*p);

   } ;

 inline void base::show(________________)

  {

    cout<<p- >x<<'',''<<p- >y<<endl;

  }

  void print( base *p)

  {

     p -> show(p);

}

  void main( )

  {

    base a;

a.initxy( 67 ,90);

    print(________________);

  }

49.下面程序給出了一個(gè)從普通的基類(lèi)派生出一個(gè)模板類(lèi)的方法,在下劃線處填上正確的

    部分(答案寫(xiě)在“答題紙’’上)。

    #include <iostream>

    using namespace std ;

 class Base

    {

public:

      Base( int a){x=a;}

      int Getx(){return;}

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

    private:

      int x;

 } ;

    template <class T>

    class derived: public Base

    {

    public:

      derived(T a,int b): ________________

    {y=a;}

      T Gety(){return y;}

      void showd(){cout<<y<<'' ''<<Getx()<<endl;}

private:

________________

    } ;

    void main( )

    {Base A(458);

A.showb( );

    derived<char *>B ''It is'',1 357);

B.showd( );

    }

50.下面程序的運(yùn)行結(jié)果如下:

    20,22

    60,22

    將下劃線處缺少的部分寫(xiě)在“答題紙’’上。源程序如下:

    #include <iostream>

    using namespace std;

    class base

    {

private:

      const int a;

      static const int b;

    public:

      base(int);

      void Show( );

 };

    ________________=22;

    ________________:a( i ){}       //初始化

    void base::Show( )

    {cout<<a<<”,”<<b<<endl;}

    void main( )

    {

 base al(20),a2(60);

      a1.Show( );

      a2.Show( );

 }

 

責(zé)編:may1205
惠水县| 全州县| 土默特右旗| 彭水| 海城市| 永和县| 昌平区| 惠州市| 徐闻县| 瓦房店市| 杭锦后旗| 江川县| 凤城市| 深圳市| 涞水县| 克山县| 清水县| 莒南县| 襄汾县| 瑞金市| 洪江市| 和林格尔县| 佛冈县| 平遥县| 庆云县| 宁南县| 昌吉市| 斗六市| 周至县| 沽源县| 扶风县| 北碚区| 进贤县| 固安县| 平安县| 上栗县| 类乌齐县| 太和县| 长顺县| 关岭| 乌兰察布市|