全国2013年10月自学考试C++程序设计真题(打印word版)(四)

时间:2015-02-09 18:51:58

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G

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.下面程序的运行结果如下:

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

 }


首页 上页 3 4 5 下页 尾页 4/7/7
微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】
 ★ 自学考试省级导航 ★ 
全国 A安徽 B北京 C重庆 F福建 G广东 广西 甘肃 贵州 H河南 河北 湖南 湖北 黑龙江 海南 J江苏 江西 吉林 L辽宁 N内蒙古 宁夏 Q青海 S山东 山西 陕西 四川 上海 T天津 X新疆 西藏 Y云南 Z浙江 历年真题分类检索
 ★ 自学考试导航 ★ 
 ★ 自考报名 ★ 

电脑版  |  手机版  |  返回顶部