官术网_书友最值得收藏!

Comments

In C++, it is possible to insert comments to describe and clarify the meaning of the program. The comments are ignored by the compiler (every comment is replaced by a single space character). There are two types of comments: line comments and block comments. Line comments start with two slashes and end at the end of the line.

cout << "Hello, World!" << endl; // Prints "Hello, World!".

Block comments begin with a slash and an asterisk and end with an asterisk and a slash. A block comment may range over several lines.

/* This is an example of a C++ program.
   It prints the text "Hello, World!"
   on the screen. */

#include <iostream>
using namespace std;

void main()
{
  cout << "Hello, World!" << endl; // Prints "Hello, World!".
}

Block comments cannot be nested. The following example will result in a compile-time error.

/* A block comment cannot be /* nested */ inside another
   one. */

A piece of advice is that you use the line comments for regular comments, and save the block comments for situations when you need to comment a whole block of code for debugging purposes.

主站蜘蛛池模板: 都兰县| 新建县| 灵宝市| 南木林县| 曲水县| 太原市| 蕉岭县| 房产| 定安县| 连云港市| 梁平县| 武胜县| 凌源市| 阜新市| 遂平县| 中西区| 嘉兴市| 织金县| 荔浦县| 普定县| 平山县| 天津市| 扶风县| 海丰县| 枣强县| 云梦县| 育儿| 博白县| 乾安县| 孝感市| 麦盖提县| 托克逊县| 枝江市| 兴化市| 应城市| 永靖县| 林州市| 罗定市| 同心县| 随州市| 英超|