This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| cplus [2024/06/20 10:36] – ↷ Links adapted because of a move operation jasonwch | cplus [2024/06/20 11:03] (current) – jasonwch | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | Comments C++ C++ language Basic Concepts Comments serve as a sort of in-code documentation. When inserted into a program, they are effectively ignored by the compiler; they are solely intended to be used as notes by the humans that read source code. Although specific documentation is not part of the C++ standard, several utilities exist that parse comments with different documentation formats. | ||
| + | |||
| + | Syntax /* comment */ (1) comment (2) 1) Often known as “C-style” or “multi-line” comments. 2) Often known as “C++-style” or “single-line” comments. All comments are removed from the program at translation phase 3 by replacing each comment with a single whitespace character. C-style C-style comments are usually used to comment large blocks of text, however, they can be used to comment single lines. To insert a C-style comment, simply surround text with /* and */; this will cause the contents of the comment to be ignored by the compiler. Although it is not part of the C++ standard, / and */ are often used to indicate documentation blocks; this is legal because the second asterisk is simply treated as part of the comment. C-style comments cannot be nested. C++-style C++-style comments are usually used to comment single lines, however, multiple C++-style comments can be placed together to form multi-line comments. C++-style comments tell the compiler to ignore all content between and a new line. Notes Because comments are removed before the preprocessor stage, a macro cannot be used to form a comment and an unterminated C-style comment doesn' | ||
| + | |||
| + | |||
| + | ^ ^ ^ | ||
| + | | line3 | <fc # | ||