| C++ |
一、CPP(C++) 開發工具: 本例使用工具:Notepad++ 參考:如何在Notepad++編譯 c & c++ 語言 其它工具:Dev-C++ 二、基本C++語言程式
#include
#include
using namespace std;
int main(void)
{
string str("Hello! World!");
cout << endl;
cout << str << endl;
return 0;
}三、基本格式說明: 註解方式: 多行註解: /* 這裡面是註解 */ 單行註解://這後面是註解,不可換行。 程式說明:
#include
// 引入標準程式庫中的字串相關的程式
#include
// std 為標準程式庫的名稱空間
using namespace std;
int main(void)
{
// 建立變數名稱為 str , 資料型態為 string 物件
// str 括弧是 string 的建構子
// str("存放文字")
string str("Hello! World!");
// 使用 cout 輸出資料
// 使用 ENDL 為換行符號 \n
cout << endl;
cout << str << endl;
return 0;
}三、程式執行 圖1:
相關參考: [C]C語言_基本格式(Hello! World!)
文章標籤
全站熱搜
