[]:只有兩個中括號,完全不抓取外部的變數。
[=]:所有的變數都以傳值(by value)的方式抓取。
[&]:所有的變數都以傳參考(by reference)的方式抓取。
[x, &y]:x 變數使用傳值、y 變數使用傳參考。
[=, &y]:除了 y 變數使用傳參考之外,其餘的變數皆使用傳值的方式。
[&, x]:除了 x 變數使用傳值之外,其餘的變數皆使用傳參考的方式。
// 不寫參不傳參
[](void) { cout << "Hello, Lambda" << endl; }; //void可寫可不寫
int n;
cout << n << endl;
// 變成lambda 運算式 // 寫參傳參
[](int n) { cout << n << endl; }
(int)a在誇號選擇要轉換的型態,char轉int會直接轉ascllint num = '5' - '0', 這個答案會是 5to_string(int)while(cin >> 變數)
{
每次輸入變數時,要做什麼事...
}
////////////////////////////////////
while(cin >> n, n)
{
n為0時跳出迴圈
}
///////////////////////////////////
while((ch=cin.get())!=EOF) // get all char and output
{
cout<<(char)ch;
}
i=func();呼叫func()函數,並將回傳值給i存放sizeof(array) 可以表示矩陣數目,這個也可以判斷變數在記憶體裡面的大小(byte)#include<string>
stoi(): string 轉 intstoll(): string 轉 long long int