1 / 18

第十三章 复 习

第十三章 复 习. 主要内容包括: 1. 基本知识点 2. 习题讲解 3. 期末考试题型. 知识点. 面向对象方法学的基本理论 C++ 语言基础 封装性 继承性 多态性 模板 异常处理. 第一章 面向过程与面向对象的程序设计. 本章的主要目的是 理解 面向过程的程序设计和面向对象的程序设计在本质上有什么 不同 。主要从以下几个方面来讲解: 计算机的工作过程 面向过程的程序设计 面向对象的程序设计. 第二章 面向对象方法学导论. 主要内容包括: 1. 基本概念 2. 面向对象建模 3. 对象模型 ( 重点掌握 )

benita
Télécharger la présentation

第十三章 复 习

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第十三章 复 习 主要内容包括: 1. 基本知识点 2. 习题讲解 3. 期末考试题型

  2. 知识点 • 面向对象方法学的基本理论 • C++语言基础 • 封装性 • 继承性 • 多态性 • 模板 • 异常处理

  3. 第一章 面向过程与面向对象的程序设计 • 本章的主要目的是理解面向过程的程序设计和面向对象的程序设计在本质上有什么不同。主要从以下几个方面来讲解: • 计算机的工作过程 • 面向过程的程序设计 • 面向对象的程序设计

  4. 第二章 面向对象方法学导论 主要内容包括: 1. 基本概念 2. 面向对象建模 3. 对象模型(重点掌握) 4. 面向对象分析 5. 面向对象设计 6. 面向对象实现

  5. 接口 公有 属性 公有 操作 数据 内部操作1 内部操作2

  6. 封装性 主要内容包括: 1. 类的定义 2. 数据成员(const、static、动态、对象成员) 3. 成员函数定义(构造和析构函数、内联函数) 4. 类的调用(一般调用、动态调用、对象数组)

  7. 继承性 继承是面向对象程序设计的重要特点之一,继承能提高软件的重用性。通过本章的学习,要求掌握以下内容: 1、能通过继承已有的类建立新类; 2、掌握派生类和基类的概念; 3、掌握继承的三种方式:公有继承、保护继承、私有继承;4、掌握派生类的构造函数和析构函数;5、理解多重继承和虚基类; 6、赋值兼容性。

  8. 第八章 重 载 主要内容包括(掌握重载的基本概念) 1.函数重载的定义、条件及注意事项; 2.什么是运算符重载,运算符重载的语法和使用时的注意事项;运算符重载为成员函数

  9. 多态性 主要内容包括: 1. 静态联编中隐含的问题 2. 虚函数(声明及使用) 3. 纯虚函数及抽象类

  10. 模板 主要内容包括: 1. 类模板 2. 函数模板

  11. 复习材料 课件(教材) 期中考试题 实验手册

  12. 习 题 例:编写一个学生和教师的数据输入和显示输出的程序。学生的相关数据包括编号、姓名和总成绩,教师的相关数据包括编号、姓名和职称。 设计一个基类Person,该类中包括有关编号和姓名的输入和输出。另设计一个Student类和一个Teacher类作为Person的派生类。最后使用一个主函数来验证该程序的功能。 要求: 1、画出类间的关系图; 2、给出完整的程序。

  13. 习题 • 分析简答题 重载(重载的条件)、虚基类(多重继承的二义性,如何解决)、虚函数(静态联编带来的问题,如何解决) 例:写出下列程序运行结果,说明为什么会出现这样的结果?

  14. 派生类的初始化 例如: class Base{ int p1,p2; public: Base(int a,int b) { p1=a; p2=b; } Base(int a) {p2=a;} }; class Derived:Base{ int p3; Base obj1,obj2; // 对象成员 public: Derived(int x1,int x2,int x3,int x4,int x5):Base(x1,x2),obj1(x3,x4),obj2(x2) { p3=x5; } }; void main() { Derived d(27,28,100,200,-50);} 说明Derived类的对象d时,自动调用构造函数,结果把各个数据初始化为: p1=27, p2=28, obj1.p1=100, obj1.p2=200, obj2.p2=28, p3=-50

  15. Base Base int a int a Derived1 Derived2 DD 公共基类带来的二义性 class Base{ protected: int a; public: Base(int i) { a=i; } }; class Derived2:public Base{ int d2; public: Derived2(int x1,int x2):Base(x1) { d2=x2; } }; class Derived1:public Base{ int d1; public: Derived1(int p1,int p2):Base(p1) { d1=p2; } };

  16. 公共基类带来的二义性 class DD:Derived1,Derived2{ public: DD(int i1,int i2,int i3,int i4):Derived1(i1,i2),Derived2(i3,i4) { }; void display() { cout<<a<<endl; } //a重名 }; void main() { DD myDD(1,2,3,4); myDD.display(); }

  17. 静态联编带来的问题 void main(){ Base obj1, *ptr; Derive obj2; ptr = &obj1; ptr->who(); ptr = &obj2; ptr->who(); } 使用基类指针指向派生类对象。 class Base { public: void who() { cout<<“Base"<<endl; } }; class Derive : public Base { public: void who() { cout<<“Derive”<<endl; } }; 结果: Base Base ?

  18. 期末考试题型 一、程序运行结果(25%) 二、选择题(1%*20) 三、分析简答题(25%) 四、程序设计题(30%)

More Related