C++ Comments

The double slash (//) introduces a C++ comment. A comment is a remark from the programmer to the reader that usually identifies a section of a program or explains some aspect of the code. The compiler ignores comments. After all, it knows C++ at least as well as you do, and, in any case, it’s incapable of understanding comments. As far as the compiler is concerned, Listing 2.1 looks as if it were written without comments, like this:

#include <iostream>int main(){    using namespace std;    cout << "Come up and C++ me some time.";    cout << endl;    cout << "You won't regret it!" << endl;    return 0;}

C++ comments run from the // to the end of the line. A comment can be on its own line, or it can be on the same line as code. Incidentally, ...

Get C++ Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.