设为首页    加入收藏

自学考试省级导航

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

2013年1月全国高等教育自学考试C++程序设计真题(四)
2013-03-16 17:29:02 来源:91考试网 作者:www.91exam.org 【

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

     }

 

四、完成程序题(本大题共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.下面程序的运行结果如下:

    2022

    6022

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

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

      a1Show( )

      a2Show( )

 }

 

五、程序分析题(本大题共4小题,每小题5分,共20分)

51.给出下面程序的输出结果

    #include<iostream>

    using namespace std

    class base

    {

      int x

public :

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

 int getx( ) { return x;

};

void main( )

{

      int *p;

      base a;

      a. setx ( 15) ;

  &nbs

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

网站客服QQ: 960335752 - 14613519 - 48225117