Object Oriented thinking:
is not a real thing, it is a kind of thought, programming thought;
is to put some of the life of the individual/things, write it into the program, much like the structure of the body;
All things are objects
Object-oriented three major features:
Encapsulation, inheritance, polymorphism
Object-oriented benefits: clearer structure, higher maintainability, and greater ease of program function expansion
Extended:
First, the package
The package is best understood. Encapsulation is one of the object-oriented features and is the main feature of object and class concepts.
Encapsulation, which is the encapsulation of objective things into abstract classes, and classes can put their own data and methods
Only trusted classes or object operations are allowed to hide information that is untrusted.
Ii. inheritance
One of the main functions of object-oriented programming (OOP) language is "inheritance".
Inheritance refers to the ability to use all the functions of an existing class,
and extend these features without rewriting the original classes.
New classes created through inheritance are called "subclasses" or "derived classes."
The inherited class is called the base class, the parent class, or the superclass.
The process of inheritance is from the general to the special process.
To implement inheritance, it can be implemented through inheritance (inheritance) and combination (composition).
In some OOP languages, a subclass can inherit multiple base classes.
However, in general, a subclass can have only one base class, and to implement multiple inheritance, it can be implemented by multilevel inheritance.
Inheritance concepts are implemented in three categories: implementation inheritance, interface inheritance, and visual inheritance.
Implementation inheritance refers to the ability to use the properties and methods of a base class without additional coding;
Interface inheritance refers to the ability to use only the names of properties and methods, but subclasses must provide the implementation;
Visual inheritance is the ability of a subform (class) to use the appearance of a base form (class) and to implement code.
When considering using inheritance, it is important to note that the relationship between the two classes should be a "belongs" relationship.
For example, the Employee is a person and the Manager is a person, so these two classes can inherit the People class.
But the Leg class cannot inherit the person class, because the leg is not a human.
Abstract classes only define generic properties and methods that will be created by subclasses, and when creating abstract classes, use the keyword Interface instead of class.
The development paradigm is roughly: dividing objects → abstract classes → organizing classes into hierarchical structures (inheritance and compositing)
→ Use classes and instances to design and implement several stages.
Three, polymorphic
Polymorphism (POLYMORPHISN) is a technique that allows you to set the parent object to be equal to one or more of his sub-objects,
After the assignment, the parent object can operate differently depending on the attributes of the child object that is currently assigned to it.
To put it simply, it is a sentence: A pointer to the parent class type is allowed to be assigned a pointer to the child class type.
To achieve polymorphism, there are two ways, covering, overloading.
Overwrite refers to the practice of redefining the virtual function of a parent class by a subclass.
overloading, which means that multiple functions with the same name are allowed, and the parameter tables of these functions are different (perhaps the number of arguments is different,
Maybe the parameter types are different, maybe they are different).
Object-Oriented Fundamentals