Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the C++ skills necessary to read the source code

Shulou Source: shulou.com Published: 2022-06-02 01:34:34 09月12日 Update

Read the source code necessary C++ skills, many novices are not very clear, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

C++ in the code

After reading through the source code, we can find that most of the source code is written in C and C++. I believe most of the readers are java programmers. If they are some if-else,while, these simple control flow statements should be fine, but if they are some of the characteristics of if-else,while, it is not easy to understand. This article is also the basic knowledge that I have learned to sell and sort out some C++.

Macro statement

The macro statement in the source code is as follows:

The place of use is shown in the following figure:

We can see from the figure that using GB/KB/MB directly, such as line 891, can also be written as * result = n * (1024UL * MB) * (1024UL), so macro statements can be brought directly into the

The use of colons and # in C++

Four positions in the following function in the source code are excerpted to explain:

one。 Type##OopDesc

The double # sign here is used for string concatenation. If the incoming type is instance, then the 144th line is instanceOopDesc.

two。 Class type##Oop: pubic oop

The colon means inheritance on the class.

three。 Type##Oop (const oop$ o): oop (o) {}

The one after the constructor: acts as a partition and is used to assign values to class member variables

four。 Backslash\

Line continuation characters, because the macro definitions in C++ must be on the same logical line, so it looks convenient to use\, and they are treated as one line at run time

The use of pointer * and addressing symbol &

The pointer has always been a difficult problem in Cstroke +. When I used to learn this area, I used to compare the room number, such as a knife. I live in room 0157. That 0157 is my address. & the value of the knife is 0157. If a pointer variable of a * p knife is defined. Then the value of * p knife is the knife itself. Without the * sign, the value of the p knife is 0157. Hold on to this example and think about it step by step.

The simplest code and debugging results are as follows:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Source code Clippers knives that is statements pointers colons functions variables rooms knowledge problems help skills clarity one line bit code function example Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn macOS Linux Redmi