- 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.
推薦閱讀
- 中文版AutoCAD 2016從入門到精通
- 零基礎學后期:Photoshop+Lightroom數碼照片處理從新手到高手
- Oracle Siebel CRM 8 User Management: LITE
- MATLAB 2015從入門到精通
- MATLAB 2022a從入門到精通
- Vue 企業開發實戰
- CINEMA 4D R20完全實戰技術手冊
- ASP.NET Core 3從入門到實戰
- Oracle Warehouse Builder 11g R2: Getting Started 2011
- AI繪畫+LoRA模型訓練從新手到高手
- 機械CAD軟件應用入門指導書
- Photoshop CC圖形圖像處理實戰教程(微課版)
- Funambol Mobile Open Source
- OpenCms 7 Development
- UG NX 9.0模具設計工廠實訓