Kinds of Comments in C++
There are two kinds of comments in C++: single-line and paired. A single-line comment starts with a double slash (//
) and ends with a newline. Everything to the right of the slashes on the current line is ignored by the compiler. A comment of this kind can contain any text, including additional double slashes.
The other kind of comment uses two delimiters (/*
and */
) that are inherited from C. Such comments begin with a /*
and end with the next */
. These comments can include anything that is not a */
, including newlines. The compiler treats everything that falls between the /*
and */
as part of the comment.
A comment pair can be placed anywhere a tab, space, or newline is permitted. Comment pairs can span multiple lines ...
Get C++ Primer, Fifth Edition 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.