概念"/>
Concepts of Class 类的概念
Concepts of Class 类的概念
1. OO Programming Concepts (面向对象编程的概念)
Object-Oriented Programming (OOP) involves programming using objects. (OOP利用对象进行程序设计)
An object represents an entity in the real world that can be distinctly identified. (一个对象表示现实世界中一个独一无二的实体)
For example, a student, a desk, a circle, a button, and even a loan can all be viewed as objects.
例如,一个学生,一张桌子,一个圆圈,一个按钮,甚至一笔贷款都可以看成是对象
2. Features of OO (面向对象的特征)
(1) Abstraction (抽象)
(2) Polymorphism (多态)
(3) Inheritance (继承)
(4) Encapsulation (封装)
我们将这四个单词的首字母放在一起: A PIE
中文含义是:一块甜饼。 这样记忆就方便多了。
3. What does an object consist of? (对象由什么构成)
An object has a unique identity, state, and behaviors.(对象具有唯一的标识、状态和行为)
The state of an object consists of a set of data fields (also known as properties) with their current values. (对象状态由数据域(也称为“属性”)及其当前值构成)
The behavior of an object is defined by a set of functions. (对象的行为由一组函数定义)
4. How to define Objects (如何定义对象)
An object is an instance of a class (对象是类的实例)
A class includes (类包含):
(1) data fields,defined by variables(由变量定义的数据域)
(2) Behaviors, defined by functions(由函数定义的行为)
A class has two special types of functions (类中有两种特殊的函数)
(1) constructors : which are invoked automatically when constructing objects from the class. (构造函数:在创建对象时被自动调用)
(2) destructors : : which are invoked automatically when the object is destroyed. (析构函数:在对象被销毁时被自动调用)
析构/构造函数简写:ctor 和 dtor
更多推荐
Concepts of Class 类的概念
发布评论