如何預測矢量的大小?有沒有辦法通過單獨的類型獲取矢量的字節大小?
#include <vector>
#include <iostream>
using namespace std;
int main() {
cout << sizeof(vector<char[8]>) << endl;
cout << sizeof(vector<char[16]>) << endl;
return 0;
}
[[email protected] LCDControl]$ ./test
12
12
預測大小是什麼意思?在你的例子中它看起來非常可預測 - 12個字節。請記住,這是依賴於實現的。 – 2009-10-12 19:01:49