- Microsoft Visual C++ Windows Applications by Example
- Stefan Bjornander
- 192字
- 2021-07-02 12:02:20
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.
推薦閱讀
- EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g: LITE
- Adobe After Effects CC 高手之路
- AI繪畫教程:Midjourney關鍵詞靈感手冊
- Photoshop CS6完全自學案例教程(微課版)
- 照相館的故事:Photoshop CC 2018調色合成精修
- ADOBE FLASH PROFESSIONAL CS6 標準培訓教材
- UG NX 完全實例解析
- NetLogo多主體建模入門
- 老郵差·Photoshop數碼照片處理技法:人像篇(修訂版)
- 中文版3ds Max/VRay效果圖制作完全自學教程(實例培訓教材版)
- After Effects印象 影視高級特效光影篇
- NX Open API編程技術
- 計算機輔助翻譯基礎與實訓
- JBoss AS 5 Performance Tuning
- UG NX 9.0模具設計工廠實訓