< Previous | Contents | Next >

Commenting Code

The first two lines of the program are comments.

// Game Over

// A first Cþþ program

Comments are completely ignored by the compiler; theyre meant for humans. They can help other programmers understand your intentions. But comments can also help you. They can remind you how you accomplished something that might not be clear at first glance.

You can create a comment using two forward slashes in a row (//). Anything after this on the rest of the physical line is considered part of the comment. This means you can also include a comment after a piece of Cþþ code, on the same line.


Hin t

image

You can also use what are called C-style comments, which can span multiple lines. All you have to do is start the comment with /* and end it with */. Everything in between the two markers is part of the comment.

image