Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report