Only when the basic things are done well can the highest principle be produced. As programmers, especially newcomers, there are similar and relevant technical concepts, which are sometimes maddening, especially during interviews. The understanding of the concept of technology, to a certain extent, can reflect the level of a person. The following is my understanding of some technical concepts that I have been confused about. There may still be some biases, so let’s throw a brick to attract jade.
Overload, override, hide, override
- heavy load
In OOP, overloads are multiple functions with the same name in the same class. These functions with the same name have different parameter characteristics (number and type of parameters). Other features are irrelevant, such as different return value types. - Rewriting
Rewriting is a function of different classes in the inheritance system, and more specifically, it acts on the subclass, which refers to the subclass inherited from the parent classvirtual functionMake the modification to meet the requirements of the subclass. In this way, we can say that the subclass overrides the function of the parent class and produces two different functions. The parent class object calls the original function of the parent class, and the child class object calls the overridden function. -
hide
- Hiding is used in different classes in the inheritance system, which is slightly different from override. It refers to that the subclass inherits from the parent classNon virtual functions with the same parameter characteristicsperhapsFunctions of the same name with different parametersIn this way, the function of the parent class is hidden from the child class and cannot be called directly. It is equivalent to that the function of the parent class changes from the function that can be inherited by the child class to that of the parent class completely private.
-
From the perspective of scope, local variables hide global variables in local scope
int i = 1024; void swap(int& a, int& b) { Int i = a; // local I hides global I a = b; b = i; } Cout < I < endl; // global I
-
rewrite
In computer data storage, overwriting is the process of replacing old information with new information.
In computer data storage, rewriting is a process of replacing old information with new information.
-
difference
- The difference between overloading and rewriting
Overloading acts on the same class (single class), and overriding acts on parent-child classes (at least 2 classes). - The difference between rewriting and hiding
The difference lies in whether it is a virtual function with the same parameter characteristics. - The difference between rewriting and the other three
One of the most puzzling is the difference between rewriting and rewriting. In OOP, there is only rewriting. Rewriting seems to appear inexplicably. From my personal experience, it is entirely my own trouble. In a broad sense, overloading, rewriting and hiding belong to rewriting. Therefore, it is unnecessary to discuss the difference between rewriting and other three.
- The difference between overloading and rewriting
Concurrent, parallel, serial
Let’s start with an important concept,Logic control flow: a process provides an illusion to each program as if it were using the processor exclusively. The instruction sequence of the program counter (PC) in the processor is called logical control flow.
- Concurrent
The execution of a logical control flow overlaps another flow in time, which is called concurrent flow. These two flows are called concurrent runs. The general phenomenon that multiple streams execute concurrently is called concurrency. Simply put, if two streams overlap in time, they are concurrent. - parallel
If two streams run concurrently on different processors or computers, they are parallel streams. - serial
Different parts of a single logic control flow or multiple logic control flows have sequence in operation, that is, run a first, and then run B after a is finished. This execution mode is called serial. -
difference
- Concurrency and parallelism
A parallel flow is a true subset of concurrent flows. Under the condition of sufficient resources, two logic control flows execute simultaneously, which is a special case of concurrency; under the condition of insufficient resources, two logic control flows execute alternately. Whether it is executed simultaneously or alternately, it is concurrent. - Parallel and serial
The execution mode of logical control flow is different. If a and B are in the execution order, a must execute first, and B can execute only after a has finished executing, which is serial. A. B is parallel if it does not have to wait for the execution of the other party to finish.
- Concurrency and parallelism