当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

川北医学院:《C++程序设计》课程教学资源(课件讲稿)第11章 继承与派生

资源类别:文库,文档格式:PDF,文档页数:107,文件大小:4.23MB,团购合买
11.1 继承与派生的概念 11.2 派生类的声明方式 11.3 派生类的构成 11.4 派生类成员的访问属性 11.5 派生类的构造函数和析构函数 11.6 多重继承 11.7 基类与派生类的转换 11.8 继承与组合 11.9 继承在软件开发中的重要意义
点击下载完整版文档(PDF)

第11章 继承与派生 11.1继承与派生的概念 11.2派生类的声明方式 11.3派生类的构成 11.4派生类成员的访问属性 11.5派生类的构造函数和析构函数 11.6 多重继承 11.7基类与派生类的转换 11.8继承与组合 11.9继承在软件开发中的重要意义 2017年4月26日星期 第11章继承与派生 H0雪2时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 2 11.1 继承与派生的概念 11.2 派生类的声明方式 11.3 派生类的构成 11.4 派生类成员的访问属性 11.5 派生类的构造函数和析构函数 11.6 多重继承 11.7 基类与派生类的转换 11.8 继承与组合 11.9 继承在软件开发中的重要意义

Inherit and derivation of class The process of constructing a new class based on specialties of an existing class is known as inherit. The process of constructing a new class by adding self-specialties based on an existing class is named as derivation. The existing class inherited by is called basic class or father class. The new class constructed by derivation is called derived class. 2017年4月26日星期 第11章继承与派生 3 H0画2时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 3 • The process of constructing a new class based on specialties of an existing class is known as inherit. • The process of constructing a new class by adding self-specialties based on an existing class is named as derivation. • The existing class inherited by is called basic class or father class. • The new class constructed by derivation is called derived class

Example of inherit and derivation 交通工具 汽车 小汽车 卡车 旅行车 工具车 轿车 面包车 2017年4月26日星期 第11章继承与派生 4 H0雪2时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 4 工具车 轿车 面包车 小汽车 卡车 旅行车 汽 车 交 通工具

Example of inherit and derivation 动物 猴子 猫 鸟 狮子 虎 猎豹 017年4月26日星期 第11章继承与派生 HOME 5 12时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 5 猴 子 狮子 虎 猎豹 猫 鸟 动 物

Purpose of inherit and derivation Purpose of inherit: Realizing code reused. Purpose of derivation: When a new problem appears and the original program can't resolve it,we must reconstruct the original program. 2017年4月26日星期 第11章继承与派生 6 0雪2时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 6 • Purpose of inherit: Realizing code reused. • Purpose of derivation: When a new problem appears and the original program can’t resolve it, we must reconstruct the original program

11.2派生类的声明方式 class Student1:public Student/声明基类是Student public: void display_1() /新增加的成员函数 cout<<"age:"<<age<<endl; cout<<"address:"<<addr<<endl; private: int age; /新增加的数据成员 string addr; /新增加的数据成员 2017年4月26日星期 第11章继承与派生 H0画2时16分23秒 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 7 class Student1: public Student//声明基类是Student { public: void display_1( ) //新增加的成员函数 { cout<<"age: "<<age<<endl; cout<<"address: "<<addr<<endl; } private: int age; //新增加的数据成员 string addr; //新增加的数据成员 };

Mode of inherit The effect of different manner of inherit: 1.Member of derived class controls and access the member of basic class. 2.Object of derived class controls and access the member of basic class. Three types of inherit public inherit -private inherit protected inherit 2017年4月26日星期 第11章继承与派生 H0画2时16分23秒 8 BACK NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 8 • The effect of different manner of inherit: 1. Member of derived class controls and access the member of basic class. 2. Object of derived class controls and access the member of basic class. • Three types of inherit – public inherit – private inherit – protected inherit

声明派生类的一般形式为 class派生类名:[继承方式] 基类名 派生类新增加的成员 继承方式包括:public(公用的),private(私有的) 和protected(受保护的)。 如果不写此项,则默认为private(私有的)。 2017年4月26日星期 第11章继承与派生 H0画2时16分23秒 BACK NEX

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 9 声明派生类的一般形式为 class 派生类名: [继承方式] 基类名 { 派生类新增加的成员 } ; 继承方式包括: public(公用的),private(私有的) 和protected(受保护的)。 如果不写此项,则默认为private(私有的)

11.3派生类的构成 派生类中的成员包括:从基类继承来的成员; 声明派生类时增加的成员。 基类 派生类 Student类 Student1类 数据成员 int num; int num; char name[10]; 继承 char name[10]; char sex; char sex; 成员 函数 void display() void display(); int age; char addr [30]; 新增 2017年4 H0画2时1t void display(); BACK 10 NEXT

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 10 派生类中的成员包括:从基类继承来的成员; 声明派生类时增加的成员

派生类的构造 (1)从基类接收成员。派生类把基类全部的成 员(不包括构造函数和析构函数)接收过来。 (2)调整从基类接收的成员 3)声明派生类时增加的成员,体现了派生类 对基类功能的扩展。 (4)定义派生类的构造函数和析构函数,因为 构造函数和析构函数是不能从基类继承的。 派生类是抽象基类的具体实现。 017年4月26日星期 HOME 第11章 继承与派生 12时16分23秒 BACK NEX

HOME2017年4月26日星期 三12时16分23秒 第11章 继承与派生 11 派生类的构造: (1) 从基类接收成员。派生类把基类全部的成 员(不包括构造函数和析构函数)接收过来。 (2) 调整从基类接收的成员。 (3) 声明派生类时增加的成员,体现了派生类 对基类功能的扩展。 (4) 定义派生类的构造函数和析构函数,因为 构造函数和析构函数是不能从基类继承的。 派生类是抽象基类的具体实现

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共107页,可试读30页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有