python中的oop
As we have already discussed about the general concepts related to Class, Objects, Inheritance etc, using an example in the previous tutorial. In this tutorial, we will elaborate more on these topics.
正如我们已经使用上一教程中的示例讨论了与类,对象,继承等相关的一般概念一样。 在本教程中,我们将详细介绍这些主题。
对象 (Objects)
As already discussed in the previous tutorial, an object is a physical entity, whereas class is a logical defintion. An object can be anything like - a student while designing a school's record registry, or a pen in stationary's item management program, or a car in manufacture's car database program. There are three important characteristics by which it is identified, they are:
如上一教程中已讨论的,对象是物理实体,而类是逻辑定义。 对象可以是任何东西,例如,学生在设计学校的记录注册表时,或文具的物品管理程序中的笔,或制造商的汽车数据库程序中的汽车。 识别它的三个重要特征是:
Identity: Identity refers to some piece of information that can be used to identify the object of a class. It can be the name of the student, the company name of the car, etc.
身份 :身份是指可用于识别类对象的某些信息。 它可以是学生的姓名,汽车的公司名称等。
Properties: The attributes of that object are called properties. Like age, gender, DOB for a student; or type of engine, number of gears for a car.
属性 :该对象的属性称为属性。 像年龄,性别,学生DOB; 或发动机的类型,汽车的齿轮数。
Behaviour: Behaviour of any object is equivalent to the functions that it can perform. In OOP it is possible to assign some functions to objects of a class. Taking the example forward, like a student can read/write, the car can accelerate and so on.
行为 :任何对象的行为都等同于它可以执行的功能。 在OOP中