<span id="plx27"><var id="plx27"></var></span>
<dfn id="plx27"><var id="plx27"></var></dfn>
  • <span id="plx27"><code id="plx27"><input id="plx27"></input></code></span>
    <menu id="plx27"></menu><menuitem id="plx27"><thead id="plx27"><input id="plx27"></input></thead></menuitem>
  • <label id="plx27"><code id="plx27"></code></label>
    <label id="plx27"><button id="plx27"></button></label>

    面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)

    上傳人:仙*** 文檔編號:31771728 上傳時(shí)間:2021-10-12 格式:DOC 頁數(shù):20 大?。?21.50KB
    收藏 版權(quán)申訴 舉報(bào) 下載
    面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)_第1頁
    第1頁 / 共20頁
    面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)_第2頁
    第2頁 / 共20頁
    面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)_第3頁
    第3頁 / 共20頁

    下載文檔到電腦,查找使用更方便

    15 積分

    下載資源

    還剩頁未讀,繼續(xù)閱讀

    資源描述:

    《面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)》由會員分享,可在線閱讀,更多相關(guān)《面向?qū)ο蟪绦蛟O(shè)計(jì)(C++)(雙語)(20頁珍藏版)》請?jiān)谘b配圖網(wǎng)上搜索。

    1、江西財(cái)經(jīng)大學(xué)06-07學(xué)年第一學(xué)期期末考試試卷試卷代碼: 03874B 課時(shí): 64學(xué)時(shí)課程名稱:面向?qū)ο蟪绦蛟O(shè)計(jì)(C+)(雙語) 適用對象:05級信管、信計(jì)一、Single-Choice (Every question is 2 point, total is 32 point)1、( ) has the same function as the sentence: printf(“Hello worldn”) in C language.A. cout”Hello worldn” B. cin”Hello worldn”C. cout”Hello worldn” D. cin”Hello

    2、worldn”2、The result of the program is ( ).#include double f(double x, int n) double val = 1.0; while (n-)val = val*x;return(val); void main(void) cout f(5,2) endl; A. 10 B. 7 C. 25 D. 33、For pointers, ( ) is not right.A. int i; int* ptr=&i B. int i; int *ptr; i=*ptrC. int *ptr; ptr=0 D. int i=5; int

    3、 *ptr; *ptr=i4、In the following functions, ( ) can not be overloaded.A. Common member functions B. Common non-member functionsC. Destructor D. Constructor5、After executing the following program, ( ) is the result.#includevoid Swap(int a, int b)int t;t=a;a=b;b=t;int main() int x=5, y=10; Swap(x,y); c

    4、outx=x y=yendl; return 0; A. x=5 y=10 B. x=10 y=5 C. x=5 y=5 D. x=10 y=106、If a derived class is gained from a base class by private inherit, the private and public members in the base class will become ( ) members for derived class. A. public B. private C. protectedD. friend7、For operator overloadi

    5、ng, ( ) is correct.A. The number of operands can be changedB. The priority for operators can be changed C. The syntax for operators cant be changedD. The combination sequence can be changed8、( ) is not right for the description of class.A. Class is a user defined type B. The private members can be a

    6、ccessed by friend functions in classC. In class, without declaration the member data are private D. In class, without declaration the member functions are public9、Given a class MyClass, after executing the sentence: MyClass a, b, *p, the constructor will be called ( ) times.A. 1 B. 2 C. 3 D. 410、The

    7、 default constructor can exist in the situation of ( ).A. All the timeB. No copy constructor is givenC. No constructor with arguments is givenD. No constructor is given 11、A friend function in a class or a friend class can access ( ) of the class. A. public members B. protected members C. private me

    8、mbers D. all members12、For static member data, it is initialized at().A. Before the declaration of class and after the main functionB. Before the main function and after the declaration of classC. In the classD. In the main function13、( ) is equal to the sentence: while(!x).A. x=1 B. x!=1C. x!=0 D.

    9、x=014、For macros, ( ) is the result of the following program.#include #define ONE 1#define TWO ONE+ONE#define THREE ONE+TWOvoid main() coutTHREEendl; cout(TWO)*5endl;A. 2 10 B. 1 10 C. 3 10 D. 0 015、In the case of ( ), it can be used inline functions.A. There are cycle sentences in the function like

    10、 for(int i)B. There are recursive sentences in the functionC. In order to speed the functionD. There are many codes in the function and they are not frequently used 16、For the descriptions of pure virtual functions and abstract class, () is wrong.A. Pure virtual function is a special function withou

    11、t given definitionsB. Abstract class is a class with pure virtual functionsC. If a base class has pure virtual functions, the derived class form it will never be abstract class D. Abstract class can be used as base class, the pure virtual functions in it will defined in the derived class二、Judgment,

    12、if it is right please otherwise . (Every question is 2 point, total is 18 point)1、C+ is a sub-set of C, it reserves almost all the characteristics of C.-2、Given int a; int b=a; a=10; b=20; if couta,b; the result is: 20,20.-3、Given class AB, the copy constructor can be defined as: AB:AB(const AB &).-

    13、4、Both constructor and destructor can not be overloaded.-5、If class B is a friend of class A, then all member functions of class B can access the members in class A, vice versa.-6、For a non-member operator overloading function, a mode computation can de defined as: X operator%(X), where X is the nam

    14、e of a class.-7、No objects of an abstract base class can be instantiated.-8、Given class B int x; /*.*/; we can define class D: public Bint z; public: void SetXZ( int a, int c) x=a; z=c; int Sun() return x+z;-9、Object of a base class can be treated as an object of the derived class.- 三、Complete the p

    15、rogram (3*5=15) (Every question is 5 point, total is 15 point) (attention: one line for just one sentence)1、After the main function, the result is: x=0;y=0x=3;y=5x=3;y=5Destructor is called.Destructor is called.Destructor is called.Please complete the program.#include void main()demo d;d.show();demo

    16、 d1(3,5); d1.show(); demo d2(d1); d2.show();class demoint x, y;public:-x=a; y=b;- x=d.x;y=d.y;- - void show()-;2、#include #include class personchar *Name;int Age;public:person(char * name, int age); person();char *GetName()return Name;int GetAge()return Age;void show(); ;person:person(char * name, i

    17、nt age) - Age=age;person:person()delete Name;void person:show() coutGetName()tGetAge()endl;class student :public personchar *Department; int Number;public:student(char *, int , char*, int);student() delete Department;void SetDep(char *) / the implementation is omittedvoid SetNum(int num) Number=num;

    18、 char *GetDep() return Department;int GetNum() return Number;-Number=num;3、The following program is used to calculate the distance between two points, please complete the program.#include #include class Pointpublic: Point(double xx=0, double yy=0) X=xx;Y=yy; double GetX() return X; double GetY() ret

    19、urn Y; -private:double X,Y;double Dist( Point& a, Point& b) - - return sqrt(dx*dx+dy*dy);int main() Point p1(3.0, 5.0), p2(4.0, 6.0); - coutThe distance is dendl; return 0;The result is-四、Read the program and write out the result. (Every question is 5 point, total is 20 point)1、Please write the resu

    20、lt of the following program:#include int sub(int n)int a; if(n=1) return 1; a=n+sub(n-1); return(a); void main() int i=5; coutsub(i)endl; 2、Please write the result of the following program:#include class testprivate:int num;float fl;public:test( );int getint( )return num;float getfloat( )return fl;t

    21、est( );test:test( )coutInitalizing defaultendl;num=0;fl=0.0;test:test( )coutDestructor is activeendl;void main( )test array2;coutarray1.getint ( ),array1.getfloat()endl;3、Please write the result of the following program:#include#includeclass Student string name;public: static int num; Student (strin

    22、g& str) name = str; +num; ;int Student:num = 0; int main() Student s1(Smith), s2(“John”); cout”Student:num=” Student:num “n”; Student s3(Marry), s4(“Tom”); cout s3.num= s3.num endl;cout s4.num= s4.num endl;4、Please write the result of the following program:#include class B1 public:B1(int i) coutcons

    23、tructing B1 iendl;B1() coutdestructing B1 endl;class B2public:B2(int j) coutconstructing B2 jendl;B2() coutdestructing B2 endl;class B3public:B3() coutconstructing B3 *endl;class C: public B2, public B3, public B1 public:C(int a, int b, int c, int d): B1(a),memberB2(d),memberB1(c),B2(b)coutconstruct

    24、ing Cendl;C() coutdestructing C endl;private:B2 memberB2;B1 memberB1;B3 memberB3;void main()C obj(1,3,5,7);五、Programming (The question is 15 point)According to the description, design a program with main function. (Description: In the first step, please declare an abstract class Shape. Then, based o

    25、n it two classes named Rectangle and Circle are derived. In both the two classes, the functions GetArea() calculating for the area and GetPeri() calculating for the perimeter must be involved.) 江西財(cái)經(jīng)大學(xué)06-07學(xué)年第二學(xué)期期末考試試卷試卷代碼: 03874A 課時(shí): 64學(xué)時(shí)課程名稱:面向?qū)ο蟪绦蛟O(shè)計(jì)(C+)(雙語) 適用對象:計(jì)算機(jī)及其相關(guān)專業(yè) 試卷命題人:楊勇 試卷審核人:舒蔚 I、Singl

    26、e-Choice (Every question takes 2 points, the total score is 32 points)1、When we input “ Tao Zou” , the output of the following program is ( ) consequently.#include#include using namespace std;int main( ) string str; coutplease enter your namestr; couthello, str!n;A. hello, Zou! B. hello, Tao! C. hel

    27、lo, Tao Zou! D. hello,!2、The statement ( ) is not the characteristic of the standard library. A. It supports Strings and I/O streamsB. B. It supports the C standard library with very minor modifications C. It Supports for numerical computation D. It supports compiling checking errorsE.3、After execut

    28、ing the following program, ( ) is the running result.#includelong fac(int n) long f; if (n1) f=n*fac(n-1); else f=1; return f;void main() coutfac(6)endl;A. 120 B. 720 C. 30. D . 14、Given a class MyClass, after executing the sentence: MyClass a2, b, *p, the destructor MyClass( ) will be called ( ) ti

    29、mes.A. 1 B. 2 C. 3 D. 45、In order to improve the speed of the function, the function can be written as ( ). A. Inline function B. Function overloading C. Recursive function D. Friend function6、The running results of the program are ( ). #include void func(int p, int &q) int t; t=p; p=q; q=t; void ma

    30、in() int x=1,y=2; func(x,y); coutx”,”yendl;A. 1, 2 B. 2, 1 C, 1, 1 D. 2, 27、For functions with default arguments, ( ) is not wrong.A. int add(int x,int y=5,int z=6)B. int add(int x=1,int y=5,int z)C. int add(int x=1,int y,int z=6)D. int add(int x,int y=5,int z)E.8、C+ has the following characteristic

    31、s except ( ). A. Polymorphism B. Object C. Abstract D. Inheritance 9、One of the following description is right, it is ( ).A. C+ is a sub-set of C, it reserves almost all the characteristics of CB. Both constructor and destructor can not be overloadedC. If class B is a friend of class A, then class A

    32、 is also the friend of class BD. No objects of an abstract base class can be instantiated10、For a non-member operator overloaded function, a mode computation can de defined as( ).A. X operator%(const X)B. X operator%( const X, const X)C. X operator%( )D. void operator%( const X, const X)11、( ) is no

    33、t true for the description of constructor.A. The constructor should have the same name as the class nameB. The system will automatically call the constructor during defining objectC. No returning type for the constructorD. The constructor can have just only one12、Among the following descriptions, (

    34、) is not correct.A. Inside inline function, there is no cycle and switch sentences.B. Using the same name for operations on different types is called overloadingC. Given the function prototype: double sqrt(double), we can write cout sqrt(three)D. The form of operator overloading for prefix increment

    35、 is like: type operator +()13、For virtual functions, among the following declarations ( )is right.A. Virtual functions can be defined as friend functionsB. Virtual functions can be overloadedC. Constructors can be virtual functions, while destructors cannotD. Virtual functions cannot be defined as s

    36、tatic functions14、If we want to define a friend function of class AB, we can define it as:A. void friend func(AB&)B. friend func(AB&)C. friend int func(AB&)D. friend void func()15、About class and object, ( ) is wrong.A. A class can just have one object B. Class is an abstract of one type of objectsC

    37、. Object is an instance of a class D. The relation like the variables and their type 16、For static member data, it is initialized at().E. Before the declaration of class and after the main functionF. Before the main function and after the declaration of classG. In the class declarationD. In the main

    38、 functionII、True or False (Six programs are given in the following, for each of them, if it is defined correctly, please mark “” for it, else please mark “” and point out the wrong sentences or sentence. Each question takes 3 points, the total score is 18 points)1、void main() int *p= new int(3); int

    39、 *q; q=p; cout*pendl; p+=3;/ other operations delete p; 2、class rectangle public:Rectangle( ); Rectangle(int width=4, int length=6); Rectangle() private: int width; int length; ;int main() Rectangle rect1; Rectangle rect2(4,5); 3、class StudentID public: StudentID(int id) value=id; coutAssigning stud

    40、ent idvalueendl; protected: int value;class student public: student(char * pName=no name, int ssID=0) coutConstructing student,pNameendl; protected: StudentID id;void main() Student s(“Randy”,9818);student t(“Jenny”);4、class Pointpublic:Point(double xx=0, double yy=0) X=xx;Y=yy;double GetX() return

    41、X;double GetY() return Y;friend double Dist(Point &a, Point &b); private:double X,Y;double Point :Dist( Point& a, Point& b) double dx=a.X-b.X; double dy=a.Y-b.Y; return sqrt(dx*dx+dy*dy);5、class A public: void setA(int); void showA(); private: int a;class B public: void setB(int); void showB();priva

    42、te: int b;class C : public B, A public: void setC(int, int, int); void showC();private: int c;int main() C obj; obj.setA(5); obj.showA(); obj.setC(6,7,9); obj.showC();obj.setB(6); obj.showB(); 6、class A public: void f();void g();class B public: void f(); void g();class C: public A, public B public:

    43、void g(); void h();void main() C c;c. g();c. f(); III、Complete the program (Every question takes 5 points, the total score is 15 points) (Note: one line for only one C+ sentence)1、 According to the running results of the following program, please complete the program.Results: 9 18 27 3210#include us

    44、ing namespace std;class myclass int num; -public:myclass(int x)num=x;- myclass() sum=sum-1; - - void display() coutnumtsumendl; ; - void main() myclass a(9); a.display(); myclass b(8); b.display();- c.display(); 2、#include #include class personchar *Name;int Age;public:person(char * name, int age);

    45、person();char *GetName()return Name;int GetAge()return Age;void show(); ;person:person(char * name, int age) - Age=age;person:person()delete Name;void person:show() coutGetName()tGetAge()endl;class student :public personchar *Department; int Number;public:student(char *, int , char*, int);student()

    46、delete Department;void SetDep(char *) / the implementation is omittedvoid SetNum(int num) Number=num; char *GetDep() return Department;int GetNum() return Number;-Number=num;3、After the main function, the running results are: constructer be called.birthday:1988-10-25number:12345 sex:f id:9destructor

    47、 be called.Please complete the program.#include using namespace std;class birthdayprivate: int year, month, day; public: birthday(int Year,int Month,int Day)year=Year; month=Month; day=Day; - void show() cout birthday: year-month-dayendl; ;class people private: - int number; char sex; int id;public:

    48、 people(int n,char m,int s,birthday d) number=n ;sex=m;id=s; b=d; coutconstructer be called.endl; people()- void display(); ; void people:display() - coutnumber:numbert sex:sextid:idendl;void main() birthday d(1988,10,25); people c(12345,f,9,d);-IV、Read the following programs and write down the runn

    49、ing results (Every question takes 5 points, the total score is 20 points)1、Please write down the running results of the following program:#includeclass simplecat public: simplecat(int age=1, int weight=2); int GetAge() return itsage; int GetWeight() return itsweight; private: int itsage; int itsweig

    50、ht; ; simplecat:simplecat(int age, int weight) itsage=age; itsweight=weight;void main()simplecat F1; coutF1.GetAge()tF1.GetWeight()endl;simplecat F2(5); coutF2.GetAge()tF2.GetWeight()endl; simplecat F3(5,8); coutF3.GetAge()tF3.GetWeight()endl; 2、Please write down the running results of the following

    51、 program:#include class Cint d;static int s;public:C(int a=0) d=a; s+; int GetD() return d;int GetS() return s;void SetD(int a) d=a;int C:s=0;void main()C c5;for (int i=0; i5; i+)ci.SetD(i+1);for (i=0; i5; i+)coutci.d=ci.GetD()tci.s=ci.GetS()endl; 3、Please write down the running results of the followin

    展開閱讀全文
    溫馨提示:
    1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
    2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
    3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
    4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
    5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
    6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
    7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

    相關(guān)資源

    更多
    正為您匹配相似的精品文檔
    關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

    copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

    備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


    本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!

    欧美久久久一区二区三区,国产精品亚洲一区二区无码,亚洲国产精品综合久久20声音,亚洲国产精品无码久久久蜜芽
    <span id="plx27"><var id="plx27"></var></span>
    <dfn id="plx27"><var id="plx27"></var></dfn>
  • <span id="plx27"><code id="plx27"><input id="plx27"></input></code></span>
    <menu id="plx27"></menu><menuitem id="plx27"><thead id="plx27"><input id="plx27"></input></thead></menuitem>
  • <label id="plx27"><code id="plx27"></code></label>
    <label id="plx27"><button id="plx27"></button></label>