设为首页    加入收藏

自学考试省级导航

全国 A安徽 B北京 C重庆 F福建 G广东 广西 甘肃 贵州 H河南 河北 湖南 湖北 黑龙江 海南 J江苏 江西 吉林 L辽宁 N内蒙古 宁夏 Q青海 S山东 山西 陕西 四川 上海 T天津
     X新疆 西藏 Y云南 Z浙江 历年真题分类检索

全国2013年1月自学考试C++程序设计真题(打印word版)(五)
2015-02-09 17:52:43 来源:91考试网 作者:www.91exam.org 【

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

46.将下划线处缺少的部分写在“答题纸”上。源程序如下:

   #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.将下划线处缺少的部分写在“答题纸’’上。源程序如下:

 #include <iostream>

    #include <fstream>

    using namespace std ;

    void main( )

    {

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

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

     myf. close( );

    }

48.在下面程序中的下划线处填上适当的程序(答案写在“答题纸’’上),使程序的输出

结果如下:

 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.下面程序给出了一个从普通的基类派生出一个模板类的方法,在下划线处填上正确的

    部分(答案写在“答题纸’’上)。

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

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

      a1.Show( );

      a2.Show( );

 }

 

Tags:自学考试 历年真题
】【打印繁体】 【关闭】 【返回顶部
上一篇浙江省2012年7月高等教育自学考试.. 下一篇浙江省2012年10月高等教育自学考..

网站客服QQ: 960335752 - 14613519 - 48225117