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

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.

主站蜘蛛池模板: 全南县| 常州市| 宣武区| 仪征市| 抚松县| 麦盖提县| 和田市| 芦溪县| 博乐市| 南京市| 昌宁县| 如东县| 大悟县| 屏东市| 孟州市| 布尔津县| 云和县| 大理市| 吉安县| 沾益县| 磴口县| 广东省| 高雄县| 乌兰浩特市| 昭觉县| 玉树县| 怀来县| 普宁市| 巴青县| 惠东县| 丽水市| 车险| 凤城市| 图片| 琼结县| 平邑县| 鄢陵县| 洪洞县| 包头市| 永平县| 图们市|