List of package meanings

encapsulation

Encapsulation is the combination of abstracted data and behavior (or function) to form an organic whole, that is, the organic combination of data and the source code of operating data to form a "class", in which data and functions are both classes member.

The purpose of encapsulation is to enhance security and simplify programming. Users do not need to know the specific implementation details, but only use the members of the class with specific access rights through the external interface.

The meaning encapsulated in network programming, when an application transmits data using TCP, the data is sent into the protocol stack, and then passes through each layer one by one until it is sent into the network as a series of bit streams, where each layer receives The data needs to add some headers.

in principle

1. Hide as many things as possible. Provide a simple interface to the outside world.

2 Hide all attributes.

For example, on the basis of abstraction, we can encapsulate the data and functions of the clock to form a clock class.

In C++ syntax, the clock class is declared as follows:

class Clock

{

public: //Common members, external interface

void SetTime (int NewH, int NewM, int NewS);

void ShowTime();

private: //Private member, not accessible from outside

int Hour,Minute,Second;

}

 

It can be seen that through encapsulation, some members act as the interface between the class and the outside world, while other members are hidden, so as to achieve reasonable control of member access rights, reduce the interaction between different classes to a minimum, and enhance the Data security and ease of writing programs.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324865224&siteId=291194637