Comments are parts of the source code disregarded by the compiler. They simply do nothing. Their purpose is only to allow the programmer to insert notes or descriptions embedded within the source code.
C++ supports two ways to insert comments:1 2 |
|
The first of them, known as line comment, discards everything from where the pair of slash signs (
//
) is found up to the end of that same line. The second one, known as block comment, discards everything between the /*
characters and the first appearance of the */
characters, with the possibility of including more than one line.We are going to add comments to our second program:
1 2 3 4 5 6 7 8 9 10 11 12 |
| Hello World! I'm a C++ program |
If you include comments within the source code of your programs without using the comment characters combinations
//
, /*
or */
, the compiler will take them as if they were C++ expressions, most likely causing one or several error messages when you compile it.
0 comments:
Post a Comment