第08章取其精华发挥优势概要1.pptVIP

  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文档。上传文档
查看更多
第08章取其精华发挥优势概要1

第8章继承 8.1.1派生类定义 从一个或多个以前定义的类(基类)产生新类的过程称为派生,这个新类又称为派生类。 类的继承(inheritance)是指新类从基类那里得到基类的特征,也就是继承基类的数据和函数。 派生的新类同时也可以增加或重新定义数据和操作,这就产生了类的层次性。 派生就是创建一个具有别的类的属性和行为的新类的能力。 在此,已有的类称为“父类”或“基类”,新建的类称为“子类”或“派生类”。 “狗”和“黑狗” 举个简单的例子:“狗”和“黑狗”。当谈论“狗”的时候,知道它是哺乳动物,有4条腿,1条尾巴,喜欢啃肉骨头,……现在谈论“黑狗”,人们会怎么说呢? 一种是说“黑狗是一种哺乳动物,有4条腿,1条尾巴,喜欢吃肉骨头,……,并且它的毛是黑色的”。 另一种是说:“黑狗就是黑毛狗”。 “狗”和“黑狗”之间存在一条重要的联系,那就是所有的“黑狗”都是“狗”,或者说,“黑狗”是一类特殊的“狗”。根据这一条,“狗”所具有的特征,例如4条腿,1条尾巴等,“黑狗”自然都具有。 多重继承与单继承 派生类和基类的关系 【源程序】Mobile类 【运行结果】 My number is 1321101101 Answering number is 1391101104 Answering in... Hanging up... ---Info of this Phone--- OS is Android Memory is:768MB My number is 1321101108 请按任意键继续. . . 8.2 继承方式 【源程序】 【源程序】 【运行结果】 Dialing on... Hanging up... My number is 1321101101 Answering number is 1391101104 Answering in... Hanging up... ---Info of this Phone--- OS is Android Memory is:768MB My number is 1321101108 【源程序】 例8-4 Person-Student 【运行结果】 --模拟U盘写-- --模拟U盘读-- 劝学 三更灯火五更鸡, 正是男儿读书时。 黑发不知勤学早, 白首方悔读书迟。 --模拟MP3播放-- play hello.mp3 coutinput the information of collegestudent:endl; cin classteacher; CollegeStudent student2( stdno , name , age ,classname , schoolname ,classteacher ) ; coutthe information of collegestudent is:endl; student2.show(); char tutor[20] ; char projectname[50] ; coutinput the information of graduatestudent:endl; cin tutor projectname; GraduatedStudent student3(stdno,name,age,classname, schoolname,classteacher,tutor, projectname); coutthe information of graduatestudent is:endl; student3.show(); * char researchname[50] ; coutinput the information of doctorstudent:endl; cin researchname; DoctorStudent student4(stdno,name,age,classname,schoolname,classteacher,tutor, projectname,researchname) ; coutthe information of doctorstudent is:endl; student4.show(); return 0 ; } * 【运行结果】 input the information of student: 1 john 20 computer01 jiaotong the information of student is: 1 john 20 computer01 jiaotong input the information of collegestudent: teacherwang the information of

文档评论(0)

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

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

1亿VIP精品文档

相关文档