C/C++ 的差異
基本上C++是C的強化版,C能用的C++都可以 (有少數例外)
C static function是指function只能在檔案的scope存在
C/C++ const convention
https://en.wikipedia.org/wiki/Const_(computer_programming)
C++變數可以要用再宣告,可以省記憶體 (也許程式沒執行到那邊),但降低可讀性
data和使用的地方接近也可增加效率
C要宣告在最前面
C才有VLA (Variable-length array)
Names at file scope that are const and not extern have external linkage in C (as the default for all file-scope declarations), but internal linkage in C++.
boolean
C Bool, 4 bytes
C++ bool, 1 byte
C static function是指function只能在檔案的scope存在
C/C++ const convention
https://en.wikipedia.org/wiki/Const_(computer_programming)
C++變數可以要用再宣告,可以省記憶體 (也許程式沒執行到那邊),但降低可讀性
data和使用的地方接近也可增加效率
C要宣告在最前面
C才有VLA (Variable-length array)
Names at file scope that are const and not extern have external linkage in C (as the default for all file-scope declarations), but internal linkage in C++.
boolean
C Bool, 4 bytes
C++ bool, 1 byte
留言
張貼留言