How does the compiler process C++ Comments?

As a part of the compiler, the Lexical Analyzer scans the characters and transforms them into tokens with no passing of the commented text to the parser. Since Comments do not contribute to the functionality of the program they are simply omitted at the time of compilation. Accordingly, we can understand that comments are just text in programs that are ignored by the compiler.



C++ Comments

Comments in C++ are meant to explain the code as well as to make it more readable. When testing alternative code, it can also be used to prevent execution. The purpose of the comments is to provide information about code lines. Programmers commonly use comments to document their work.

Similar Reads

Why Comments are used in C++?

Comments in C++ are used to summarize an algorithm, identify a variable’s purpose, or clarify a code segment that appears unclear. Comments are also used for:...

Types of Comments in C++

In C++ there are two types of comments :...

1. Single Line Comment

In C++ Single line comments are represented as // double forward slash. It applies comments to a single line only. The compiler ignores any text after // and it will not be executed....

2. Multi-Line Comment

...

How does the compiler process C++ Comments?

A multi-line comment can occupy many lines of code, it starts with /* and ends with */, but it cannot be nested. Any text between /* and */ will be ignored by the compiler....