<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>

            計算機二級《C++》上級考試試題及答案

            時間:2025-12-15 12:56:13 報名

            計算機二級《C++》上級考試試題及答案2017

              一、基本操作題

            計算機二級《C++》上級考試試題及答案2017

              1請使用VC6或使用【答題】菜單打開考生文件夾projl下的工程projl。程序中位于每個“/pic/p>

              Name:Smith Age:21 ID:99999 CourseNum:12

              Record:970

              注意:只修改每個“/pic/p>

              #include

              using namespace std;

              class Studentlnfo

              {

              protected:

              /pic/p>

              char Name;

              int Age;

              int ID:

              int CourseNum;

              float Record;

              public:

              Studentlnfo(char*name,int Age,int ID,int coumeNum,float record);

              /pic/p>

              void~Studentlnfo(){}

              float AverageRecord(){

              return Record/CourseNum;

              }

              void show()const{

              cout<<”Name:”<

              <<”CourseNum:”<

              }

              };

              /pic/p>

              StudentInfo StudentInfo(char*Name,int Age,int ID,int CourseNum,float Record)

              {

              Name=name;

              Age=age;

              this一>ID=ID:

              CourseNum=courseNum:

              Record=record;

              }

              int main()

              {

              Studentlnfo st(’’Smith”,21,99999,12,970);

              st.show();

              return 0;

              }

              參考解析:

              (1)char*Name;

              (2)~Studentlnfo(){}

              (3)Studentlnf0::Studentlnfo(char*name,int age,,int ID,int eourseNum,float record)

              二、簡單應用題

              2請使用VC6或使用【答題】菜單打開考生文件夾proj2下的工程proj2,其中定義了vehiele類,并派生出motorcar類和bicycle類。然后以motorcar和bicycle作為基類,再派生出motorcycle類。要求將Vehicle作為虛基類,避免二義性問題。請在程序中的橫線處填寫適當的代碼并刪除橫線,以實現上述類定義。此程序的正確輸出結果應為:

              80

              150

              100

              1

              注意:只能在橫線處填寫適當的代碼,不要改動程序中的其他內容,也不要刪除或移動“/pic/p>

              #include

              class vehicle

              {

              private:

              int MaxSpeed;

              int Weight;

              public:

              /pic/p>

              vehicle(int maxspeed,int weight):——

              ~vehicle(){};

              int getMaxSpeed(){return MaxSpeed;}

              int getWeight(){retum Weight;}

              };

              /pic/p>

              class bicycle:——public vehicle

              {

              private:

              int Height;

              public:

              bicycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),Height(height){}

              int getHeight(){retum Height;};

              };

              /pic/p>

              class motorcar:——public vehicle

              {

              private:

              int SeatNum;

              public:

              motorcar(int maxspeed。int weight,int seatnum):vehicle(maxspeed,weight),SeatNum(seatnum){}

              int getSeatNum(){return SeatNum;};

              };

              /pic/p>

              class motorcycle:——

              {

              public:

              motorcycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),bicycle(maxspeed,weight,

              height),motorcar(maxspeed,weight,1){}

              };

              void main()

              {

              motorcycle a(80,150,100);

              cout<

              cout<

              cout<

              cout<

              }

              參考解析:

              (1)MaxSpeed(maxspeed),Weight(weight){f;

              (2)virtual

              (3)virtua1

              (4)public bicycle,public motorcar


            更多計算機二級C++相關試題分享:

            1.2017年3月計算機二級C++考前練習題及答案

            2.2017計算機二級C++模擬題及答案

            4.2017年3月計算機二級C++練習題及答案

            5.2017計算機二級C++基礎習題及答案

            6.2017計算機二級C++考點習題及答案

            7.2017年12月計算機二級C++考前練習題及答案

            8.2017計算機二級C++強化習題及答案

            9.2017計算機二級C++強化習題及答案

            10.計算機二級考試C++練習及答案

              三、綜合應用題

              3請使用VC6或使用【答題】菜單打開考生文件夾proj3下的工程文件proj3。本題創建一個小型字符串類,字符串長度不超過l00。程序文件包括pmj3.h、proj3.cpp、writeToFile.obj。補充完成重載賦值運算符函數,完成深復制功能。

              屏幕上輸出的正確結果應該是:

              Hello!

              Happy new year!

              補充編制的`內容寫在“/pic/pic/p>

              不得修改程序的其他部分。

              注意:

              程序最后調用writeToFil。函數,使用另一組不同的測試數據,將不同的運行結果輸出到文件0ut•dat中。

              輸出函數writeToFile已經編譯為obj文件。

              /pic/p>

              #include

              #include

              using namespace std;

              class MiniString

              {

              pubhc:

              friend。8tream&operator<<(oatream&output,const MiniString&s)/pic/p>

              { output<

              friend istream&operator>>(istream&input,MiniString&8)/pic/p>

              { char temp[100];/pic/p>

              temp[0]=’\0’:/pic/p>

              input>>setw(100)>>temp;

              int inLen=strlen(temp);/pic/p>

              if(inLen!=0)

              }

              s.1ength=inLen;/pic/p>

              if(s.sPtr!=0)delete[]s.sPtr;/pic/p>

              s.sPtr=Hew char[s.1ength+1];

              strcpy(s.sPtr,temp);/pic/p>

              }

              else s.sPtr[0]=’\0’;/pic/p>

              retum input;

              }

              void modString(const char}string2)/pic/p>

              {

              if(strin92 1=0)/pic/p>

              {

              if(strlen(strin92)!=length)

              {

              length=strlen(strin92);

              delete[]sPtr;

              sPtr=new char[1ength+1];/pic/p>

              }

              strcpy(sPtr,strin92);

              }

              else sPtr[0]=’\0’;/pic/p>

              }

              MiniString&operator=f const MiniString&otherString);

              MiniString(corot char*s=""):lengtll((s!=0)?strlen(s):0)/pic/p>

              {

              sPtT=0:

              if(1ength[=0)

              setString(S);

              }

              ~MiniString()/pic/p>

              {delete[]sPtr;}

              private:

              int length;/pic/p>

              char*sPtr;/pic/p>

              void setString(const char*string2)/pic/p>

              {

              sPtr=Dew char[str|en(string2)+1];/pic/p>

              if(stnIl92!=0)strcpy(sPtr,string2);/pic/p>

              else slur[0]='\0';/pic/p>

              }

              };

              /pic/p>

              #'include

              #include

              using namespace std;

              #include”proj3.h”

              MiniString&MiniStrin9::0perator=(const MiniString&otherString)

              {/pic/p>

              /pic/p>

              /pic/p>

              }

              int main()

              {

              MiniSu'ing strl(”Heuo!”),str2;

              void writeToFile(const char*);

              sir2=strl;/pic/p>

              str2.modString("Happy new year!");

              cout<

              cout<

              writeToFile("");

              return 0;

              }

              參考解析:

              length=otherString.1ength; /pic/pic/pic/p>


            更多計算機二級C++相關試題分享:

            1.2017年3月計算機二級C++考前練習題及答案

            2.2017計算機二級C++模擬題及答案

            4.2017年3月計算機二級C++練習題及答案

            5.2017計算機二級C++基礎習題及答案

            6.2017計算機二級C++考點習題及答案

            7.2017年12月計算機二級C++考前練習題及答案

            8.2017計算機二級C++強化習題及答案

            9.2017計算機二級C++強化習題及答案

            10.計算機二級考試C++練習及答案

            【計算機二級《C++》上級考試試題及答案】相關文章:

            計算機二級C++考試試題及答案10-13

            全國計算機二級考試C++精選試題及答案12-28

            計算機二級c++試題及答案12-24

            2016計算機二級《C++》考試試題及答案10-13

            計算機二級考試C++上機考試試題及答案02-08

            2016計算機二級考試C++備考試題及答案02-06

            2016年計算機二級考試C++試題及答案03-17

            全國計算機二級考試《C++》強化試題及答案02-25

            計算機二級考試C++試題及答案(通用5套)10-21

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院