dynamic –> runtime 才去 cast
static –> compile time 就幫你試過
其他所有Manipulators都是sticky
位元AND運算(&), 位元OR運算(|), 位元XOR運算(^)
將原先的資料型別換成二進位表示之後再做運算
error: 'to_string' was not declared in this scope
自己寫:
check if myStream.rdbuf()->in_avail() == 0
https://stackoverflow.com/questions/8046357/how-do-i-check-if-a-stringstream-variable-is-empty-null
cin.get() 有三种格式
无参,一参数,二参数
cin.get() , cin.get(char ch) , cin.get(array_name,Arsize)
cin.getline()只有一种格式
cin.getline(array_name,Arsize)
Unix系統––––->“\n”;
Windows系統––>“\r\n”;
Mac系統––––->“\r”。
一個直接後果是,Unix/Mac系統下的文件在Windows裡打開的話,所有文字會變成一行;
而Windows裡的文件在Unix/Mac下打開的話,在每行的結尾可能會多出一個^M符號。
format specifier | meaning |
---|---|
%c | char |
%d | 10 進位 int |
%o | 8 進位 int |
%u | unsign int |
%x, %X | 將int以 16 進位方式輸出 (x大小寫決定英文字輸出大小寫) |
%f | float |
%e, %E | 用科學記號顯示float (e大小寫決定英文字e輸出大小寫) |
%g, %G | 等同使用 %f 或 %e(%f 或 %E) 兩方案電腦自行判斷哪個表示精簡 |
%% | 顯示 % |
%s | string |
%lu | long unsigned 型態的整數 |
%p | pointer |
輸出浮點數指定精度:
printf("example:%.2f\n", 19.234);
%.2f 指定小數點後取兩位
靠右對齊:
printf("example:%6.2f\n", 19.234);
%6f 預留 6 個字元寬度
靠左對齊:
printf("example:%-6.2f\n", 19.234);
加負號
預留的寬度想用變數:
printf("example:%*f\n", x, 19.234);
用*
scanf()
若已是字元陣列就不用 & 取址
重載資料流運算子
若Object是宣告為const,則只能執行const member function
default argument 只能出現一次
https://pinglinblog.wordpress.com/2014/01/16/ctype-uint8_t-uint16_t-uint32_t-uint64_t/
Sun, Aug 13, 2017 12:37 PM
C和C++在宣告結構的變數時不同
宣告結構時一起宣告變數 C和C++沒差
Chen.Ken=10; //設定Ken=10;
Chen.Sam=10.5;
polymorphism 也可以傳reference
base class 的 destructor 前面要加virtual
http://vincecc.blogspot.tw/2013/10/cc-typedef-struct-typedef-struct.html