欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    第四套模拟试题.docx

    • 资源ID:3812736       资源大小:26.61KB        全文页数:22页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    第四套模拟试题.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()


    注意事项

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

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

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


    收起
    展开