华南俳烁实业有限公司

自考

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

排行熱點

全國2013年10月自學(xué)考試C++程序設(shè)計試題_第6頁

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

49.下面程序給出了一個從普通的基類派生出一個模板類的方法,在答題紙上填上缺少的

 部分。

    #include <iostream>

    using namespace std;

    class Base

    {

    public:

      Base(int a){x=a;}

      int Getx(){return x;

      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<<" "<<Gets ( )<< endl;}

 private:

                  

} ;

   void main ( )

   { Base A(458);

 A.showb ( );

 derived < char * >B ("It is" ,1357);

      B.showd ( );

 }

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

 20,22

 60,22

   在答題紙上填上缺少的部分。源程序如下:

 #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);

 al. Show ( );

 a2. Show ( );

 }

責(zé)編:may1205
遵义市| 改则县| 安丘市| 镇巴县| 北海市| 正镶白旗| 闻喜县| 岫岩| 牟定县| 通许县| 广河县| 新民市| 卢氏县| 兴海县| 保亭| 遵义县| 湾仔区| 新泰市| 洪泽县| 三门县| 都昌县| 延边| 彰化县| 华坪县| 德保县| 开阳县| 微山县| 赤城县| 旬阳县| 宣城市| 民勤县| 福州市| 和平县| 阿拉善盟| 惠东县| 呼玛县| 镶黄旗| 福清市| 绍兴县| 保定市| 佛教|