Introduction to C + + language and Oo thought
Features of C + + and OO thought
The C language has one advantage, that is, its speed can be very fast. The written program can be very concise, simple, small, not to solve a problem around the Pacific Ocean a big circle.
However, if C and C + + are compared, C + + is often used to solve a problem around a large circle, so the code is relatively large, and there are some not necessary code.
But C + + has an absolute advantage, that is, for different objects to do the instantiation, this is the so-called Oo thought.
What is Oo thinking
In the mind of the object, anything can be regarded as an object. A complex model structure is made up of tens of thousands of objects. This is the fundamental thought.
For example, the earth can be regarded as a rather complex object. Every animal on earth, every plant, air, water, soil, etc. are objects.
They are interconnected, combined, and eventually form the Earth. For each object, abstraction can eventually be divided into two elements: properties and behavior.
In the face of object programming, programmers no longer face a function and variables, but to look at the overall situation, the face of the object to see the problem.
Each object is a complete, independent entity that is separated from the outside world by a combination of related properties and behaviors.
For example, such as our graphical user interface (GUI) programming, object-oriented capabilities in this respect are so great that people in those languages that do not directly support object-oriented (for example, c) also create some software constructs that mimic oo for GUI programming. Typical example: gnome/gtk+ tool.
The characteristics of Oo thought
1. Encapsulation
Encapsulation means combining the properties and methods of an object into a single system unit and hiding the inner details of the object as much as possible.
Encapsulation is the basis of object-oriented thought description, so the programmer is not confronted with many complex functions and process implementations, but a few individual instances of behavioral behavior.
2. Abstraction
Abstract process is the process of summarizing the specific problem, and it is the process of the unified description of a class of public problems. In order for the necessary information to be communicated smoothly, the designer must develop an abstraction, like an agreement, an agreement that is supported by an effective individual for all participating activities.
For example, the bakery provides an abstraction-"order".
3. Inheritance
A subclass object has all the same properties and methods as its base class, called Inheritance.
This fact is easiest to understand: for example, people share some properties: nose, eyes, mouth ... And some methods: eating, sleeping, *&*&
Can then be based on the whole Asian, European, African ...
Finally, I created the Asian beauty Little red ...
4. polymorphic
Polymorphism refers to properties and behaviors defined in a base class that inherit from a quilt class, and can have different data types or performance behaviors.
If the animal is a base class, its sub-categories are tigers, rabbits, dogs, birds ...
Then as the animal has a behavior defined as Move (), then these subclasses will inherit from their own characteristics to take a different personality move () way.
C + + Learning notes------c + + language and Oo thought introduction