# 開始來學C++ - C++ - 副檔名是`*.cpp` - 使用`g++.exe`編譯 ```cpp= #include <iostream> //io:輸入輸出 stream:溪流 c++省去*.h的副檔名 using namespace std; int main(){ return SUCCESS; //可省略,某些環境SUCCESS=0 } ``` - 前置處理器 - `#define`:定義 用法 ```cpp= #define SUCCESS 0 ``` - C++的語法 - `cout`:物件(顯示器標準輸出) - c:物件 - out:輸出 - <<:傳回左邊的stream ```cpp= cout << "你好啊"; ``` - `cin` ```cpp= int x; cin >> x; //輸過去 cout << "你輸入了:" << x; ``` - 字串的改良 ```cpp= #include <string> ... ... ... ``` ```cpp=+ string x; cin >> x; ``` 一個字串輸出排版範例 ```cpp= cout << "Hi" << endl << x << endl << "Are you happy"; //結束再加分號就好 ``` - 換行`endl`=`\n` - 播放音樂 ```cpp= #include <windows.h> ... ... ... PlaySound("音樂檔路徑",NULL,SND—FILENAME); ``` `libwinmm`:Windows用的多媒體庫 - 核心函數 - 相對為 非核心函數 - 一個c++的遊戲引擎:SFML/Graphics.hpp - 可以方便做有圖形的小遊戲