next up previous
Next: Header Files Up: Overview of C++ Previous: Compiling the Program

Comment Statement

A comment statement is where the programmer place a remark in the source code. The content of the comment is ignored by the compiler. Usually comments are introduced in the source code to explain and describe the operations in the source code to remind the programmer and explain the operation to anyone reading the source code. In C++ there are two types of comments. The first kind is used when multi-line comments are introduced such as

/* Program #1 -My first C++ program
After typing this program save it in program1.cpp in your directory
**/

Where the comment statement starts with /* and ends with */. Any thing between those marks is a comment and will be ignored by the compiler. The second type of comments is a single line comment. It starts with // and stops at the end of the line. An example of this kind is found in the source code as:

// main ( ) is where program execution begins

Typically, C++ programmers use multi-line comments when writing larger, more detailed commentaries, and single line comments when writing short comments.



Yousef Haik
2/23/1998