面向對象程序設計(C++)(雙語)

上傳人:仙*** 文檔編號:31771728 上傳時間:2021-10-12 格式:DOC 頁數(shù):20 大?。?21.50KB
收藏 版權申訴 舉報 下載
面向對象程序設計(C++)(雙語)_第1頁
第1頁 / 共20頁
面向對象程序設計(C++)(雙語)_第2頁
第2頁 / 共20頁
面向對象程序設計(C++)(雙語)_第3頁
第3頁 / 共20頁

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

15 積分

下載資源

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

資源描述:

《面向對象程序設計(C++)(雙語)》由會員分享,可在線閱讀,更多相關《面向對象程序設計(C++)(雙語)(20頁珍藏版)》請在裝配圖網(wǎng)上搜索。

1、江西財經(jīng)大學 06-07學年第一學期期末考試試卷 試卷代碼: 03874B 課時: 64學時 課程名稱:面向對象程序設計(C++)(雙語) 適用對象:05級信管、信計 一、Single-Choice (Every question is 2 point, total is 32 point) 1、( ) has the same function as the sentence: printf(“Hello world\n”) in C language. A. cout>>”Hello world\

2、n” B. cin>>”Hello world\n” C. cout<<”Hello world\n” D. cin<<”Hello world\n” 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) <<

3、 endl; } A. 10 B. 7 C. 25 D. 3 3、For pointers, ( ) is not right. A. int i; int* ptr=&i B. int i; int *ptr; i=*ptr C. int *ptr; ptr=0 D. int i=5; int *ptr; *ptr=i 4、In the following functions, ( ) can not be overloaded. A. Common member function

4、s B. Common non-member functions C. Destructor              D. Constructor 5、After executing the following program, ( ) is the result. #include void Swap(int a, int b) { int t; t=a; a=b; b=t; } int main() { int x=5, y=10; Swap(x,y); cout<<"x="<<

5、x<<" y="<

6、end 7、For operator overloading, ( ) is correct. A. The number of operands can be changed B. The priority for operators can be changed C. The syntax for operators can’t be changed D. The combination sequence can be changed 8、( ) is not right for the description of class. A. Class is a user de

7、fined type B. The private members can be accessed by friend functions in class C. In class, without declaration the member data are private D. In class, without declaration the member functions are public 9、Given a class MyClass, after executing the sentence: MyClass a, b, *p, the constructor

8、will be called ( ) times. A. 1 B. 2 C. 3 D. 4 10、The default constructor can exist in the situation of ( ). A. All the time B. No copy constructor is given C. No constructor with arguments is given D. No constructor is given 11、A friend function in a c

9、lass or a friend class can access ( ) of the class. A. public members B. protected members C. private members D. all members 12、For static member data, it is initialized at(). A. Before the declaration of class and after the main function B. Before the main function and after the declaration

10、 of class C. In the class D. In the main function 13、( ) is equal to the sentence: while(!x). A. x==1 B. x!=1 C. x!=0 D. x==0 14、For macros, ( ) is the result of the following program. #include #define ONE 1 #define TWO ONE+ONE #define THREE ONE+TWO

11、void main() { cout<

12、er to speed the function D. 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 without given definitions B. Abstract class is a class with pure vi

13、rtual functions C. 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, if it is right please √otherwise . (Every question i

14、s 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 cout<

15、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), whe

16、re X is the name 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 B{ int z; public: void SetXZ( int a, int c) { x=a; z=c;} int Sun() { return x+z;}};------------ 9、Object of a base

17、class can be treated as an object of the derived class.------------ 三、Complete the program (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=0 x=3;y=5 x=3;y=5 Destructor is called...

18、 Destructor is called... Destructor is called... Please complete the program. #include void main() { demo d; d.show(); demo d1(3,5); d1.show(); demo d2(d1); d2.show(); } class demo{ int x, y; public: -------------①---------{x=a; y=b;} -------------②-

19、----------- { x=d.x; y=d.y; } -------------③-------- {-----------④--------------} void show() { -------------------⑤--------------------------------- } }; 2、#include #include class person{ char *Name; int Age; public: person(char * name, int ag

20、e); ~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() {

21、 cout<

22、p() {return Department;} int GetNum(){ return Number;} }; --------------------------③-------------------------------------------- { --------------------------④--------------------- --------------------------⑤--------------------- Number=num; } 3、The following program is used to calcul

23、ate the distance between two points, please complete the program. #include #include class Point {public: Point(double xx=0, double yy=0) {X=xx;Y=yy;} double GetX() {return X;} double GetY() {return Y;} -----------------①--------------------------- private:

24、 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); ----------------④-------------------- cout<<"The distance is "<

25、 } The result is------------⑤---------------- 四、Read the program and write out the result. (Every question is 5 point, total is 20 point) 1、Please write the result of the following program: #include int sub(int n) { int a; if(n==1) return 1; a=n+sub(n-1); return(a);

26、 } void main() { int i=5; cout< class test{ private: int num; float fl; public: test( ); int getint( ){return num;} float getfloat( ){return fl;} ~test( ); }; test::test( ){ cout<<"Init

27、alizing default"< #include< string.h> class St

28、udent{ string name; public: static int num; Student (string& 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="<<

29、s3.num <

30、B2 "<

31、 {cout<<"destructing C "<

32、 class Shape. Then, based on 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.) 江西財經(jīng)大學 06-07學年第二學期期末考試試卷 試卷代碼: 03874A 課時:

33、 64學時 課程名稱:面向對象程序設計(C++)(雙語) 適用對象:計算機及其相關專業(yè) 試卷命題人:楊勇 試卷審核人:舒蔚 I、Single-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 #inclu

34、de using namespace std; int main( ) { string str; cout<<"please enter your name"<>str; cout<<"hello, "<

35、ibrary. A. It supports Strings and I/O streams B. B. It supports the C standard library with very minor modifications C. It Supports for numerical computation D. It supports compiling checking errors E. 3、After executing the following program, ( ) is the running result. #inclu

36、de long fac(int n){ long f; if (n>1) f=n*fac(n-1); else f=1; return f; } void main() { cout<

37、s( ) will be called ( ) times. A. 1 B. 2 C. 3 D. 4 5、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 function 6、The running results of the prog

38、ram are ( ). #include void func(int p, int &q) { int t; t=p; p=q; q=t; } void main() { int x=1,y=2; func(x,y); cout<

39、ng. 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 characteristics except ( ). A. Polymorphism B. Object C. Abstract D. Inheritance 9、One of the following

40、description is right, it is ( ). A. C++ is a sub-set of C, it reserves almost all the characteristics of C B. Both constructor and destructor can not be overloaded C. If class B is a friend of class A, then class A is also the friend of class B D. No objects of an abstract base class can be inst

41、antiated 10、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 not true for the description of constructor. A. The constructor should

42、 have the same name as the class name B. The system will automatically call the constructor during defining object C. No returning type for the constructor D. The constructor can have just only one 12、Among the following descriptions, ( ) is not correct. A. Inside inline function, there is no c

43、ycle and switch sentences. B. Using the same name for operations on different types is called overloading C. Given the function prototype: double sqrt(double), we can write cout<< sqrt("three") D. The form of operator overloading for prefix increment is like: type operator ++() 13、For virtual fu

44、nctions, among the following declarations ( )is right. A. Virtual functions can be defined as friend functions B. Virtual functions can be overloaded C. Constructors can be virtual functions, while destructors cannot D. Virtual functions cannot be defined as static functions 14、If we want to de

45、fine 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 objects C. Object is

46、 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 function F. Before the main function and after the declaration of class G. In the class declaration D. In th

47、e main function II、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

48、 *p= new int(3); int *q; q=p; cout<<*p<

49、 int width; int length; }; int main() { Rectangle rect1; Rectangle rect2(4,5); } 3、class StudentID { public: StudentID(int id) { value=id; cout<<"Assigning student id"<

50、t(char * pName="no name", int ssID=0) { cout<<"Constructing student,"<

51、 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:

52、 int a; }; class B{ public: void setB(int); void showB(); private: 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(

53、); 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: void g(); void h(); }; void main() { C c; c. g(); c. f(); } III、Complete the program (Every q

54、uestion 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 1 8 2 7 3 2 1 0 #include using namespace std; class myclass{ in

55、t num; ------------①------------------- public: myclass(int x){ num=x; -------------②---------------- } ~myclass(){ sum=sum-1; ------------------③----- ------- } void display(){ cout<

56、myclass a(9); a.display(); myclass b(8); b.display(); ------------------⑤--------------------- c.display(); } 2、#include #include class person{ char *Name; int Age; public: person(char * name, int age); ~person(); char *GetName(){return

57、Name;} int GetAge(){return Age;} void show(); }; person::person(char * name, int age){ ------------①------------------------ -------------②----------------------- Age=age; } person::~person() { delete Name; } void person::show() { cout<

58、ass student :public person{ char *Department; int Number; public: student(char *, int , char*, int); ~student() {delete Department;} void SetDep(char *) {// ……the implementation is omitted} void SetNum(int num){ Number=num;} char *GetDep() {return Department;} int GetNum(){ ret

59、urn Number;} }; --------------------------③-------------------------------------------- { --------------------------④--------------------- --------------------------⑤--------------------- Number=num; } 3、After the main function, the running results are: constructer be called. birthday:1

60、988-10-25 number:12345 sex:f id:9 destructor be called. Please complete the program. #include using namespace std; class birthday{ private: int year, month, day; public: birthday(int Year,int Month,int Day){year=Year; month=Month; day=Day;} ------------①-------------

61、----------- void show() { cout<<" birthday: "<

62、er be called."<

63、 people c(12345,f,9,d); --------------------------⑤--------------------- } IV、Read the following programs and write down the running results (Every question takes 5 points, the total score is 20 points) 1、Please write down the running results of the following program: #include cl

64、ass simplecat { public: simplecat(int age=1, int weight=2); int GetAge() { return itsage;} int GetWeight() {return itsweight;} private: int itsage; int itsweight; }; simplecat::simplecat(int age, int weight) { itsage=age;

65、 itsweight=weight; } void main() { simplecat F1; cout<

66、rogram: #include class C{ int 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 c[5]; for (int i=0; i<5; i++) c[i].SetD(i+1); for (i=0; i<5; i++) cout<<"c["<

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

相關資源

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

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

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


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

五月丁香婷婷狠狠色,亚洲日韩欧美精品久久久不卡,欧美日韩国产黄片三级,手机在线观看成人国产亚洲