Lecture 4
面向对象就是把数据和结构绑定起来,通过函数调用实现用户与数据的通信,实现操作的同时保护数据。
Objects = Attributes + Service
- Data: the properties or status
- Operations: the functions

simple e.g.
Class
Object 与 Class 的关系:

Definition of Class
- In C++, separated header and source files are used to define one class.
- Class declaration and member function prototypes are in the
.hheader file.
- All the function bodies (implementations) are in the
.cppsource file.
- PImpl technique: debatable, hides private members and removes compilation dependency
Standard Way
- 函数声明放在 header
.h中,相当于接口
- 主程序和函数实现放在
.cpp文件中
- 编译器只能看到
.cpp文件(a compile unit),每个.cpp编译生成一个.obj文件;链接器把所有.obj文件链接成一个可执行文件

Standard header file structure
防止重复定义
OOP
OOP Characteristic

Object-oriented programming

Encapsulation
- Bundle data and methods together
- Hide the details of dealing with the data
- Restrict access only to the publicized methods
Abstraction
- Abstraction is the ability to ignore details of parts to focus on high-level problems.
- Modularization is the process of dividing a whole into parts that can be built separately and interact in well-defined ways.
Loading...