C++ 入門指南 V2.00 - 單元 2 範例及練習程式碼



demo.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 引入標準程式庫中相關的輸入、輸出程式
#include <iostream>
// 引入標準程式庫中相關的字串程式
#include <string>
 
// std 為標準程式庫的命名空間
using namespace std;
  
int main(void) {
   // 下面建立名稱為 m , string 型態的物件
   // 小括弧為 string 的建構子
   // 雙引號為字串字面常數
   string m("There is no spoon.");
 
   // cout 用來輸出的物件
   // endl 為新行符號 '\n'    
   cout << endl;
   cout << m << endl;   
   cout << endl << endl;
     
   return 0;
}
  
/* 檔名: demo.cpp
   作者: Kaiching Chang
   時間: 2014-5 */

the end

沒有留言: