下载此文档

第九章 面向对象程序设计:继承.ppt


文档分类:IT计算机 | 页数:约125页 举报非法文档有奖
1/125
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/125 下载此文档
文档列表 文档介绍
第九章面向对象程序设计:继承( Inheritance )学****目标: ?能通过继承从现有的类建立新类?理解继承如何提高软件的可重用性?理解 protected 成员访问修饰符?了解继承层次中构造函数和析构函数的用法动物猫科动物发出声音进食/饮水捕食猎物喵喵叫喝牛奶捕食老鼠吼叫吃肉捕食大型猎物可重用性通过继承来实现 Introduction ? Inheritance ? Software reusability ? Create new class from existing class ? Absorb existing class ’ s data and behaviors ? Enhance with new capabilities Introduction ? Inheritance ? Derived class( 派生类) inherits from base class( 基类) ? Derived class ? More specialized group of objects ? Behaviors inherited from base class ? Can customize ? Additional behaviors ? Class hierarchy( 类层次结构) ? Direct base class( 直接基类) ? Inherited explicitly (one level up hierarchy) ? Indirect base class( 间接基类) ? Inherited two or more levels up hierarchy Introduction ? Class hierarchy( 类层次结构) ? Single inheritance( 单一继承) ? Inherits from one base class ? Multiple inheritance( 多重继承) ? Inherits from multiple base classes ? Base classes possibly unrelated( 不相干的) Introduction ? Three types of inheritance ? public ? Every object of derived class also object of base class ? Base-class objects not objects of derived classes ? Example: All cars vehicles, but not all vehicles cars Introduction ? Three types of inheritance ? public ? Can access non- private members of base class ? Derived class can effect change to private base-class members ? Through inherited non- private member functions Introduction ? Three types of inheritance ? private ? Alternative position ? protected ? Rarely used Introduction

第九章 面向对象程序设计:继承 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数125
  • 收藏数0 收藏
  • 顶次数0
  • 上传人yzhluyin1
  • 文件大小1.27 MB
  • 时间2017-02-24