ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:26.61KB ,
资源ID:3812736      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-3812736.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(第四套模拟试题.docx)为本站会员(b****4)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

第四套模拟试题.docx

1、第四套模拟试题专 业班 级学 号姓 名教研室主任(签字)学院院长(系主任)(签字) 课程 The C+ Programming Language 课程性质(必修专业限选任选) 考试方式( 闭卷 开卷)得分Part I、Selection(total questions 60 points, 2 points per question for the first 20 questions and 4 points per question for the last 5 questions.) 1. Suppose:void main()int x=5, y=7;x=x+y;y=x-y;x=x-y

2、;cout”x=”x” y=”yendl; Which of the following is correct output? A. x=7 y=5 B. x=5 y=7 C. x=7 y=7 D. x=5 y=5 2. Suppose: int x=1,y=1,z=1; -x & +y & +z; coutxtytz; Which of the following is correct output? A. 0 2 2 B. 0 1 1 C. 1 2 2 D. 1 2 13. Which of the following is correct function declaration? A.

3、 int fun(x, y) B. double fun(int x; int y)C. void fun(void) D. double fun(int x, y)4.Suppose: int k; int a33=1,2,3,4,5,6,7,8,9; for(k=0; k3; k+) coutak2-ky) ? x : y; void main() int m(2),n(3); max(m,n)-; coutm”t”n; A. 2 3 B. 3 2 C. 3 3 D. 2 2 题 号一二三四五六七八九总分得 分 7. Suppose: int i=100; int fun() static

4、 int i = 10; return +i; void main() fun(); fun(); coutfun()”, ”i; Which of the following is correct output?A.13,100 B.12,100 C.11,100 D. 10,100 8. Which of the following code marked (1), (2), (3) and (4) is wrong? class sample int n; public: sample(int val); /(1) sample(); /(2) private: int a=2.5; /

5、(3) sample(); / (4) ; A. (1)(2)(3)(4) B. (1)(2)(3) C. (2) D. (3) 9. Suppose: class Point int x_,y_; public: Point(): x_(0) , y_(0) Point(int x, int y=0): x_(x),y_(y);void main() Point a(2),b4,*c4;How many times the constructors of class Point will be called?A. 5 B. 4 C. 3 D. 2 10.Suppose:class Foo i

6、nt bar; ;which of the following is correct?A. bar is a private data member of class FooB. bar is a friend data member of class FooC. bar is a protected data member of class FooD. bar is a public data member of class Foo考生注意: 考试时间 120 分钟 试卷总分 100 分 答案写在 答题页 共 6 页 第 1 页专 业班 级学 号姓 名11. Which of the fol

7、lowing code marked (1), (2), (3) and (4) is correct function definition? class AA int a; public: int getRef() const return &a; / (1) int getValue() const return a; /(2) void set(int n) const a=n; /(3) friend void show(AA aa) const couta; /(4) A.(4) B. (3) C. (2) D. (1)12.Suppose: class MyClass publi

8、c: int number; void set(int i) number=i; ; int number=3; void main() MyClass my; int number=10; my.set(5); coutmy.number”t”; my.set(number); coutmy.number”t”; my.set(:number); coutmy.number”t”; Which of the following is correct output?A. 3 10 5 B. 3 5 10C. 5 10 3 D. 5 3 10 13. Which of the following

9、 is correct output? class AA int n; public: AA(int k) : n(k) int get() return n; int get() const return n+1; ; void main() AA a(4); const AA b(5); couta.get()b.get(); A.46 B.66C.44 D.45 共 6 页 第 2 页专 业班 级学 号姓 名14. Suppose: class MyBase private:int k; public: void set(int n) k=n; ; class MyDerived: pr

10、otected MyBase protected: int j; public: void f() j=10; void g() j=20; ; How many protected data members and function members in class MyDeriver?A. 1 B. 2 C. 3 D. 415.Suppose: class Base public: Base() cout”Base Constructor”endl; Base() cout”Base Destructor”endl; ; class Derived: public Base public:

11、 Derived() cout”Derived Constructor”endl; Derived() cout”Derived Destructor”endl; ; void main() Derived obj; Which of the following is correct output?A. Base Constructor B. Derived ConstructorDerived Constructor Base ConstructorBase Destructor Base DestructorDerived Destructor Derived DestructorC. B

12、ase Constructor D. Derived ConstructorDerived Constructor Base ConstructorDerived Destructor Derived DestructorBase Destructor Base Destructor 16.Suppose: class Base public: virtual void fun()cout1; ; class Derived : public Base public: void fun() coutfun(); delete pB;Which of the following is corre

13、ct output?A. 1 B. 12 C. 2 D. 2117. Which one of the following operators in c+ can not be overload?A. ?: B. C. & D. new18. Which of the following code marked (1), (2), (3) and (4) is wrong? class A public : void fun() ; class B public : void fun() /(1) void gun()fun(); /(2) ; class C : public A, publ

14、ic B private: int b; public : void gun() /(3) void hun() fun(); /(4) ;A.(4) B.(3) C.(2) D.(1)19. Which of the following will be called by fun(8,3.1)?A. fun(double,double)B template fun(T1,T2)C fun(double, int)D fun(char float)20.Suppose: template class TAdd T x,y; public: TAdd(T a, T b):x(a),y(b) in

15、t add() return x+y; ; void main() TAdd A(3.9,4.9); TAdd B(4.5,6.8); coutA.add()”t”B.add();which of the following is correct output?A.8 11 B.8 10 C.7 11 D.7 10 21. Suppose: class Test public: Test() n+=2; Test() n-=3; static int getNum() return n; private: static int n; ; int Test:n = 0; void main()

16、Test *p = new Test; delete p; cout”n=”Test:getNum()endl;Which of the following is correct output? A. n=2 B. n=1 C. n=0 D. n=-122. Suppose: class A public: A() coutA; ;class B : public A public: B() coutB; ;class C : public A B b; public: C() coutC; ;void main() C obj;Which of the following is correc

17、t output? A. ABAC B. AABC C.ABC D. CAB 23.Suppose: class ONE public: virtual void f() cout1; ; class TWO : public ONE public: TWO() cout2; ;共 6 页 第 3 页专 业班 级学 号姓 名class THREE : public TWOpublic: THREE() cout3; virtual void f() TWO:f(); coutf();Which of the following is correct output? A.22313 B.2131

18、3 C.2113 D.2231 24.Suppose:class Location public: Location(int xx, int yy) : x(xx),y(yy) Location& operator +(Location & offset); int getX()return x; int getY()return y; private: int x; int y;Location& Location:operator +(Location & offset) x=x+2*offset.x; y=y+2*offset.y; return *this;void main() Lo

19、cation p1(10,20),off(8,8); cout(p1.getX(),p1.getY()t; p1=p1+off; cout(p1.getX(),p1.getY()endl;Which of the following is correct output?A.(10,20) (18,28) B.(10,20) (26,36) C.(10,20) (8,8)D.(10,20) (16,16)共 6 页 第 4 页25.Suppose: template class Num T x; public: Num() Num(T x)this-x=x; Num & operator+(co

20、nst Num & x2) static Num temp; temp.x=x+x2.x; return temp; void disp() coutx=x; ; void main() Num A(2.8),B(3.8); A=A+B; A.disp();Which of the following is correct output? A. x=8 B. x=7 C. x=6 D. x=5得分Part II、Please read following programs and give the results which are marked with 【code 1】to 【code 5

21、】in programs.( Total questions 40 points, each 2 points)1. Suppose the programs output is:Ctriangle: a=3 b=4 c=5Perimeter: 12Area: 6Please write down your answer in appointed position.#include #include using namespace std;class Ctriangle public: Ctriangle(double x, double y, double z) a=x; b=y; c=z;

22、double GetPerimeter() /计算三角形周长【code 1】 double GetArea() /计算三角形面积double p = GetPerimeter()/2;return sqrt(p*(p-a)*(p-b)*(p-c); 专 业班 级学 号姓 名void display()coutCtriangle:a=a b=b c=cendl;【code 2】/调用GetPerimeter()成员函数求当前对象的周长【code 3】/调用GetArea()成员函数求当前对象的面积private: double a; double b; double c;void main()

23、【code 4】/定义一个边长为3,4,5的Triangle类的对象T【code 5】/调用T的成员函数display()输出2. Suppose the programs output is: ABA-B-A-A Please write down your answer in appointed position.#include using namespace std; class A public: A() 【code 1】/在命令行窗口输出字符串 A() 【code 2】/在命令行窗口输出字符串 ; class B : 【code 3】/类B保护派生自类A A* p; public:

24、 B() cout”B”; 【code 4】/产生一个A类的动态对象,并将首地址赋给指针p B()cout”-B”;【code 5】/释放指针p所指向的内存空间 ; void main() B obj; 3.Suppose the programs output is: Creating BEnd of BEnd of A Please write down your answer in appointed position.#include using namespace std; class A public: A()共 6 页 第 5 页【code 1】cout”End of A”end

25、l;/ A类的析构函数 ; class B: 【code 2】/类B公有派生自类A public: B()【code 3】/在命令行窗口输出字符串 B()【code 4】/在命令行窗口输出字符串 ; void main() 【code 5】/产生B类的动态对象,并将其首地址赋值给A类的指针pa delete p; /释放指针pa所指向的内存空间4. Suppose the programs output is: Cat is crying!Dog is crying! Please write down your answer in appointed position.#include using namespace std; class Animal /定义抽象类Animal public: 【code 1】/定义纯虚函数cry() ; class Cat : public Animal public: void cry() 【code 2】/在命令行窗口输出字符串class Dog : public Animal public: void cry() 【code 3】/在命令行窗口输出字符串void main() 【code 4】/声明一个指向抽象类Animal的指针pApA = new Cat(); pA-cry()

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2