Today, I checked some of the content in the header file provided by VC. Many statements are followed by backslashes. In my impression, only // indicates the annotation function, however, the backslash is only an escape character. But I have never seen a backslash after the statement! After checking, it turns out to be like this:
① Escape characters; for example, \ n indicates carriage return + line feed.
② Continue the line operator. Note that in general statements, this has nothing to do with it, during compilation, the compiler automatically connects the two sentences (note that the first character (including space) of the original line of the second line is connected to the previous line). See the following example:
int i = 1; cout<<i++ <<i++<<i++<<endl;
This is correct.
However:
int i = 1; cout< <i++<<i++<<i++<<endl;
This will cause an error.
Then:
int i = 1; cout<\ <i++<<i++<<i++<<endl;
But this is also a problem.
Then:
int i = 1; cout<\ <i++<<i++<<i++<<endl;
There is no problem!
Here, I see it!
,
In addition, you need to pay attention to the fact that the above line breaks are used to resume a row when a statement is relatively long. Another function is to use the backslash when the macro is defined as a long statement or a statement block or even a function! See the following:
Refer to Baidu knowledge
There is a formal name for this item called the line feed, which is the same as adding a don't add to the back of a common code line (VC automatically judges the line feed), but it is particularly useful in macro definition, because the macro definition must be completed in one line: # define somefun (X, a, B) if (x) x = a + B; else x = A-B; this line of definition is fine, but this code is not easy to understand and will be difficult to maintain in the future. If it is written as: # define somefun (X, a, B) if (X) X = a + B; else x = A-B; this is a good understanding, but the compiler will make an error because it will think that # define somefun (X, a, B) is a complete line. If (X) and the subsequent statements are irrelevant to # define somefun (X, a, B. in this case, we must use the following statement: # define somefun (X, a, B) \ If (x) \ x = a + B; \ else \ x = A-B; note: Do not add a line break to the last line. the pre-processor of VC automatically removes the \ and line feed carriage return before compilation, so that reading is not affected, but the logic is not affected.