First, object-oriented programming
Object-oriented--object oriented programming, short for OOP, is a programming idea.
There is another kind of programming idea- oriented to process programming. The process-oriented idea is to make a project, a thing in a certain order, from start to finish, do what first, after what, until the end. This idea is better understood, in fact, it is also a person's way of doing things, our previous programming ideas are also using this idea.
Object-oriented thinking is to divide a project, a thing into smaller projects, or into smaller parts, each part responsible for what aspects of the function, and finally by the combination of these parts become a whole. This kind of thought is more suitable for many people's Division of labor.
Ii. several concepts of object-oriented
1, Class: Class
A class is an abstraction, blueprint, prototype for a class of objects that have the same properties
Class, which is a kind, a model
2. Objects: Object
Object, that is, the concrete thing that the model created.
3. Instantiation
Turn a class into a concrete object.
A class must be instantiated before it can be called in a program, and a class can instantiate multiple objects
4. Encapsulation
The implementation details of some functions are not exposed, the assignment of data in the class, the internal invocation is transparent to the external user, which makes the class become a capsule or container, in which the bread implies the data and methods of the class.
5. Inheritance
A class can derive subclasses, properties, methods defined in the parent class, automatic quilt class inheritance
6. polymorphic
One method, multiple implementations. Polymorphic is not supported in Python
Third, the code example
1. Define a class
2. Inheritance
3. Overriding the construction method
Python Learning Note 9: Object-oriented Programming, class