C++期末测试题.docVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
C期末测试题

单项选择题(每题3分,共30分) 1、 下面选项中哪项不是面向对象程序设计的特性。( B ) A、封装性 B、相似性 C、继承性 D、多态性 2、以下哪一关键字可用于重载函数的区分–(指向) 运算符。 8、要使一个外部函数可以访问类中的private成员,方法是 在类中将该函数声明为友元函数。 9、类中的静态成员函数只能访问类中的 静态 数据成员。 10、用new 申请的内存,使用完后,必修用 delete 加以释放。 程序阅读题, 写出程序运行结果(每题5分, 共20分) 1、运行时输入 12 34 #includeiostream using namespace std; int main() { int x, y, z; cin x y; z = x + y; cout z= z endl; return 0; } 2、#includeiostream using namespace std; void Test(int x) { cout x endl; } void Test(double x) { cout x endl; } int main() { int x = 10; double y = 123.65; Test(x); Test(y); Test(x + y); return 0; } 3、#includeiostream using namespace std; class Complex { public: Complex(int x = 0, int y = 0) : x(x), y(y){} void Display() { cout x (y 0 ? + : ) y i endl; } private: int x; int y; }; int main() { Complex a(3, 8), b(4, -6); a.Display(); b.Display(); return 0; } 4、#includeiostream using namespace std; class Base { public: Base(int x) { b = x; cout Base Object Constructed endl; } ~Base() { cout Base Object Destructed endl; } int b; }; class Derevid : public Base { public: Derevid(int x, int y = 0) : Base(x) { data = y; cout Derevid Object Constructed endl; } ~Derevid() { cout Derevid Object Destructed endl; } int Calculate() { return data * 4 + b; } private: int data; }; int main() { Derevid d(2, 5); cout d.Calculate() endl; return 0; } 编程题(每题10分,共30分) 1、设计一个Circle类,用于求圆的面积和周长,并在主函数中实现应用。 #include iostream using namespace std; class circle { private: double r; public: circle(double r = 0) : r(r){} double Area(){return r * r * 3.1415926;} double circumference(){ return 2 * r * 3.1415926;} }; int main() { circle c(6.2); cout c.Area() endl; cout c.circumference() endl; return 0; } 2、定义一个string(字符串)类,其中包含用“+”运算符实现两个字符串连接的操作,并实现应用。 #include iostream using namespace std; class mystring { private: char *pc; int length; public: mystring(char *p) { length = 0; while(p[length] != 0)length ++;

文档评论(0)

abf4675328 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档