BTH001复习提纲讲义.doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
BTH001复习提纲讲义

BTH001复习提纲 BTH001期末考试题型: (1)判断分析题(3题,共6分) 判断,并简要说明 (2)名词解释(3题,共9分) 概念简要解释 (3)综合编程题(4大题,共85分) 每个大题下面细分若干小题 包括代码判断分析、代码编写等 1、类相关概念 类、属性、成员函数、常量成员函数 (class/property/constant member function) 练习, 1.1 理解常量成员函数(constant member function),在下面的Member类中,哪些函数可以定义为常量成员函数,如何定义? 1.2 实现下面类中的符号重载operator== 1.1 答案: string getName() const; string getAddress() const; string getPhoneNr() const; string toString() const; bool operator==(const Member member) const; 1.2 答案: bool Member::operator ==(const Member member) const { return this-name == member.name this-address == member.address; } 2、默认构造函数(default constructor) If no constructor is defined in a class it will get an automatically generated default constructor. Furthermore a class will automatically get agenerated Copy constructor Assignment operator Destructor If a class has member variables that are pointers it is necessary to replace the Default constructor Copy constructor Assignment operator Destructor 练习,通过默认构造函数创建对象,见No.6知识点练习。 Member memb; 3、析构函数(Destructor) If the class has at least one member variable that is a pointer it is necessary to: Deallocate the memory that has been allocated for the pointers by the object 练习,见No.16容器类知识点练习 4、复制构造函数(Copy constructor) Each class has a copy constructor. Purpose is to create an identical copy of another object. Automatically generated if not defined. If a member variable is a pointer this will result in shallow copying. ClassName(const ClassName parameterName) If the class has at least one member variable that is a pointer it is necessary to: replace the automatically generated copy construcor by implementing it Use memberwise (copy‐by‐value) copying of member variables that are not pointers Use deep copying for member variables that are pointers 练习,见No.16容器类知识点练习 5、赋值号重载(Assignment operator) Each class has an assignment operator. Purpose is to create an identical copy of another object. Automatically generated if not defined. If

文档评论(0)

441113422 + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档