簡單的C++程序例子
#include <iostream>
using namespace std;
// main() 是程序開始執行的地方
int main()
{
cout << "Hello World"; // 輸出 Hello World
return 0;
}
註釋有兩種://和/* */
但是有個特別的註釋:如下
此外,我們還可以使用 #if 0 ... #endif 來實現註釋,且可以實現嵌套,格式爲:
#if 0
code
#endif
你可以把 #if 0 改成 #if 1 來執行 code 的代碼。
這種形式對程序調試也可以幫助,測試時使用 #if 1 來執行測試代碼,發佈後使用 #if 0 來屏蔽測試代碼。
#if 後可以是任意的條件語句。
下面的代碼如果 condition 條件爲 true 執行 code1 ,否則執行 code2。
#if condition
code1
#else
code2
#endif
一、數據類型
C++數據類型