Concepts of Class 类的概念

编程入门 行业动态 更新时间:2024-10-12 03:21:11

Concepts of Class  类的<a href=https://www.elefans.com/category/jswz/34/1770069.html style=概念"/>

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 类的概念

本文发布于:2024-02-14 07:52:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1762807.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:概念   Concepts   Class

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!