本文概述
C ++注释是编译器未执行的语句。 C ++编程中的注释可用于提供代码, 变量, 方法或类的解释。借助注释, 你也可以隐藏程序代码。
C ++中有两种类型的注释。
- 单行注释
- 多行注释
C ++单行注释
单行注释以//(双斜杠)开头。让我们看一下C ++中单行注释的示例。
#include <iostream>
using namespace std;
int main()
{
int x = 11; // x is a variable
cout<<x<<"\n";
}
输出:
11
C ++多行注释
C ++多行注释用于注释多行代码。它被斜线和星号(/ ∗ ….. ∗ /)包围。让我们看一下C ++中多行注释的示例。
#include <ostream>
using namespace std;
int main()
{
/* declare and
print variable in C++. */
int x = 35;
cout<<x<<"\n";
}
输出:
35
评论前必须登录!
注册