亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      自考

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

      排行熱點

      全國2014年4月高等教育自學(xué)考試C++程序設(shè)計試題_第2頁

      來源:考試網(wǎng) [ 2014年8月6日 ] 【大 中 小】

        30.C++類中的______函數(shù)在對象的生存期結(jié)束時被自動調(diào)用。

        31.C++語言中的整數(shù)常量有四種:十進制常量、長整型常量、八進制常量和______。

        32.UML中對象之間的靜態(tài)關(guān)系是通過對象屬性之間的連接反映的,稱之為______。

        33.聲明一個常成員函數(shù)Fun,返回類型為char,第一個參數(shù)類型為int,第二個參數(shù)類型為double,則該函數(shù)的聲明原型是______。

        34.在C++語言中,利用向量類模板定義一個具有20個int類型且初值為1的向量C,實現(xiàn)此操作的語句是______。

        35.執(zhí)行下列代碼:int a=123,b=321;cout<

        36.將指向?qū)ο蟮闹羔樧鳛楹瘮?shù)參數(shù),形參是對象指針,實參是對象的______。

        37.vector類中用于返回向量中第一個對象的方法是______。

        38.C++語言中動態(tài)分配內(nèi)存的關(guān)鍵字是______。

        39.C++類成員的訪問權(quán)限有______、公有和保護三種。

        40.寫出聲明一個復(fù)數(shù)對象num的語句,并使對象被初始化為單精度2.2+1.3i,此聲明語句是______。

        三、改錯題(本大題共5小題,每小題4分,共20分)

        下面的每題中有一處錯誤,請在答題紙上寫出錯誤所在行并給出修改意見

        41.#include

        main ( ){

        int x=5,y=6;

        const int *p=&x;

        * p=y;

        cout<<*p<

        }

        42.#include

        class f {

        private:T x, y;

        public:f1(T a,T b){x=a;y=b;}

        T max( ){return(x>y)?x:y;}

        };

        main( ) {

        f a;

        a.f1(1.5,3.8);

        cout<

        }

        43.#include

        class point {

        private:float x,y;

        public:point(float a,float b){x=a;y=b;}

        f( ){x=0;y=0;}

        void getx( ){cout<

        void gety( ){cout<

        };

        main( ) {

        point a (3.5);

        a.getx( );

        }

        44.#include

        class f{

        private:float x,y;

        float get( ){return x+y;}

        public:f1(float a,float b){x=a;y=b;}

        };

        main( ) {

        f a;

        a.f1(1,3.8);

        cout<

        }

        45.#include

        class testl{

        private:Int x;

        public:testl( ){x=2;}

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

        void get(){cout<

        };

        class test2{

        private:int x;

        public:test2( ){x=3;}

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

        void get( ){cout<

        };

        class test:public testl,public test2.{

        private:int x;

        public:void set(int a){x=a;}

        void gettest( ){cout<

        };

        main( ) {

        test a;a.get( );

        }

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

        46.完成下面類中的成員函數(shù)的定義。

        class point

        {

        private:

        int m,n;

        public:

        point(int,int);

        point(point&);

        };

        point::point(int a,int b)

        {

        m=a;

        _____=b;

        }

        point::point(______)

        {

        m=t.m;

        n=t.n;

        }

        47.#include

        using namespace std;

        class base

        {

        private:int x;

        public:base(int a){x=a;}

        int get( ){return x;}

        void showbase( ) {cout<<"x="<

        };

        class Derived:public base

        {private:int y;

        public:Derived(int a,int b):base(a) {y=b;}

        void showderived( )

        {cout<<"x="<

        if(! fout.is_open( ))

        return;

        for(int i=0;i<3;i=i+1)

        fout<<"This is line"<

        fout.close( );

        fin.open("my.txt",ios::in);

        if(! fin.is_open( ))

        return;

        char str[100];

        while(______)

        {

        fin.getline(str,100);

        cout<

        }

        fin.close( );

        }

        50.求兩個浮點數(shù)之差的cha函數(shù)的原型聲明、調(diào)用方法。

        #include

        using namespace std;

        void main( )

        {

        float a,b;

        ______;∥函數(shù)cha的原型聲明

        a=12.5;

        b=6.5;

        float c=__________;∥調(diào)用函數(shù)cha

        cout<

        }

        float cha(float x,float y)

        {

        float w;

        w=x-y;

        return w;

        }

        五、程序分析題(本大題共2小題,每小題5分,共1O分)

        51.#lnclude

        void func( );

        void main( )

        {

        for(inti=0;i<6;i++)

        {

        func( );

        }

        }

        void func( )

        {

        int x=0;

        x ++;

        static int y=0;

        y ++;

        cout<<"x="<

        }

        void main( )

        {

        A a,b;

        a.Show( );

        b.Show( );

        }

        六、程序設(shè)計題(本大題共1小題,共10分)

        53.在三角形類tri實現(xiàn)兩個函數(shù),功能是輸入三個頂點坐標(biāo)判斷是否構(gòu)成等邊三角形

        #include

        #include

        class point { point

        private:float x,y;

        public:f(float a,float b){x=a;y=b;}

        f( ){x=0;y=0;}

        Void set(float a,float b){x=a;y=b;}

        float getx( ){return x;}

        noat gety( ){return y;}

        };

        class tri{

        point x,y,z;

        float s1,s2,s3;

        public....settri(....);∥用于輸入三個頂點坐標(biāo)

        ....test(....);∥用于判斷是否構(gòu)成等邊三角形

        };

        請寫出兩個函數(shù)的過程(如果需要形式參數(shù),請給出形參類型和數(shù)量,以及返回值類型)

      首頁 1 2 尾頁
      責(zé)編:duan123