Comments
Comments start with /*
and end with */
. These comments do
not nest. For example:
/* this is a comment /* still a comment */ int not_in_a_comment;
A comment can also start with //
, extending to the end of the line. For
example:
const int max_widget = 42; // Largest size of a widget
Within a /*
and */
comment, //
characters have no special meaning. Within
a //
comment, /*
and */
have no special meaning. Thus, you can “nest” one kind of comment within
the other kind. For example:
/* Comment out a block of code: const int max_widget = 42; // Largest size of a widget */ ///* Inhibit the start of a block comment const int max_widget = 10; // Testing smaller widget limit //*/
A comment is treated as whitespace. For example, str/*comment*/ing
describes two separate
tokens, str
and ing
.
Get C++ In a Nutshell 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.