Home Segments Index Top Previous Next

53: Mainline

You can include comments in C++ programs in two ways. First, whenever the C++ compiler encounters two adjacent forward slashes, //, C++ ignores both the slashes and the rest of the line on which the slashes appear:

// Short comment. 

Second, whenever C++ encounters a slash followed immediately by an asterisk, /*, C++ ignores both the /* characters and all other characters up to and including the next asterisk followed immediately by a slash, */.

/* 
Long comment ... 
that just goes on ... 
and on ... 
*/ 

If you wish to test how a program works without certain lines of source code, you can hide those lines in a comment, instead of deleting them.