Four characteristics of the C ++ package

C ++ four characteristics

As the C ++ object oriented programming language, object-oriented programming is provided (Object Oriented Programming, OOP, object-oriented programming four characteristics). Abstraction, encapsulation, inheritance, polymorphism.

The so-called abstraction , process is the definition of specific things. And understanding in a programming language is in the use of object-oriented approach to design a software system, we must first distinguish the types of things in the real world, which they have analyzed the nature and function, then they are abstract computer the virtual world makes sense entity - classes, the program is running, create an object of a class with mutual cooperation between interrelated objects to simulate real-world things. (These meaningless)

About abstract is actually an idea, we do not have too much to consider, because this idea will permeate all the time to write in with our code

In fact, not only abstraction, encapsulation, inheritance, polymorphism is a philosophy embodied, people use their way of thinking as far as possible to understand the world. Based encapsulation, inheritance, polymorphism, and three kinds of codes thought to construct, to write the program. Sealing equipment, inheritance, polymorphism can be said that metaphysical stuff, but people under the guidance of these metaphysical thought, with corresponding operation of the code, data, and other types of behavior may be practical operation. Therefore, an object-oriented sometimes also known as the three major characteristics, because these three characteristics can operate.

 

Package

Packaging is an idea, is literally put something together and installed seal it up, seal it up so what is it? what are the benefits? For chestnuts, excessive packaging of moon cake (completely transparent color). This is the moon cake package together, you can only get to know it through cover, processing personnel only allows you to understand it through the epidermis, thus avoiding you might see inside of it, so you see he wants you to see , and the benefits of doing so need not say more.

While programming is appreciated that the package in the process and the data surrounded, access to the data only through a defined interface. Object-oriented computing began in the basic notion that the real world can be represented as a series of fully autonomous, encapsulated objects that access other objects through a protected interface .

 

Because our code is not moon cake, so you do not have to hide it is fresh. What is needed is encapsulated its various data and various data of our operations.

 

And talk about the actual operation of the package on another inevitably abstract concept, I abstract here refers specifically to classes and objects . Classes and Objects is a corresponding term. Class is a collection of objects, an individual object is a class. For chestnut: you will be in your class more than eight meters tall boy into a class of people (tall), which is a class property is higher than one meter eighty, and a man on the inside of an object. As another chestnut, you will play football in your class into a class of boys, and this is another class. Then it will be higher than eight meters and will play for third division football class, which in turn is a class. Then we look at the classification criteria. Height, playing football. Then we found this standard height and playing football is not the same, is a people's inherent properties, is a people's movement. In the programming is static data members and member functions that operate (dynamic).

 

Then look at us achieve the package. Whether packaged or inherited or polymorphisms are operating in classes and objects. C ++ class keywords function may be defined, where there are three packages. Private, public and protected (relating to succession, the latter say). To sum up: simply think Classes and Objects (class C ++ in) is reflected in the abstract, inheritance, encapsulation and polymorphism is the basis of the class (class) is to be implemented.

To achieve encapsulation depends on public and private

 

Guess you like

Origin www.cnblogs.com/fqyf/p/11815308.html