C++ 注释

C++ 教程 · 2019-02-24 21:14:41

程序的注释是解释性语句,您可以在 C++ 代码中包含注释,这将提高源代码的可读性。所有的编程语言都允许某种形式的注释。

C++ 支持单行注释和多行注释。注释中的所有字符会被 C++ 编译器忽略。

C++ 注释以 /* 开始,以 */ 终止。例如:

/* 这是注释 */ /* C++ 注释也可以 * 跨行 */

注释也能以 // 开始,直到行末为止。例如:

实例

#include <iostream> using namespace std; int main() { cout << "Hello World"; // 输出 Hello World return 0; }

当上面的代码被编译时,编译器会忽略 // 输出 Hello World,最后会产生以下结果:

Hello World

在 /* 和 */ 注释内部,// 字符没有特殊的含义。在 // 注释内,/* 和 */ 字符也没有特殊的含义。因此,您可以在一种注释内嵌套另一种注释。例如:

/* 用于输出 Hello World 的注释 cout << "Hello World"; // 输出 Hello World */

点击查看所有 C++ 教程 文章: https://codercto.com/courses/l/18.html

查看所有标签

An Introduction to Genetic Algorithms

An Introduction to Genetic Algorithms

Melanie Mitchell / MIT Press / 1998-2-6 / USD 45.00

Genetic algorithms have been used in science and engineering as adaptive algorithms for solving practical problems and as computational models of natural evolutionary systems. This brief, accessible i......一起来看看 《An Introduction to Genetic Algorithms》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码