1.OOP encapsulation mainly ensures that components will not change the internal state of other components in an unpredictable way, and only those components that provide internal state change methods can access their internal state.
2. After a thing is abstracted, its own state may need to be changed under certain conditions, but this change is not allowed by other things. This change is only allowed to be executed by the operation domain identified by the thing, which can be the thing itself or other things it trusts. In this way, we can protect our data for all our abstract contents.
3.3. Inheritance of OOP. Inheritance refers to the process of obtaining inheritance information from existing classes and creating new classes. Let abstract things have the connection they deserve. Allows subclassing components to be created based on existing components, which unifies and enhances the other two features-polymorphism and encapsulation.
4. Generally speaking, components are grouped by classes, and new classes can be defined as extensions of existing classes, so that classes can be organized into a tree or mesh structure, which reflects the universality of actions.
5.5. polymorphism of OOP. According to the definition, polymorphism means that the reference and class set of components involve many other different types of components, and the results produced by referencing components depend on the actual call type.
6. In practical application, a solution is used to solve a class of problems, and the solution and result are different for different things. There are three ways to realize polymorphism in C++, namely virtual function, function overload and operator overload.
Extended data:
Advantages of OOP over process-oriented programming;
(1)OOP focuses on objects and roles, that is, the essence of things.
(2)OOP abstracts the objects in the objective world into corresponding classes; 2) constructing an instance through a class; 3) Establish the communication relationship between objects through dependence, inheritance and implementation.
(3)OOP is easy to expand, adding or changing business functions, and there is no need to make major changes to the source code.
(4)OOP is easy to model. OOP is the abstraction and representation of the objective world by software architects in high-level computer language, and people can understand and establish abstract models in computers.
Baidu encyclopedia -OOP