total memory of a C++ class object
问题 Why does the following piece of code gives 24 as an answer? That is, how is the total size of the object of following class X, 24 bytes? I'm using 64-bit machine. #include <bits/stdc++.h> using namespace std; class X { vector <bool> f; int b; public: X(){ f.push_back(true); } }; int main(){ X ob; cout<<sizeof(ob); return 0; } 回答1: That is, how is the total size of the object of following class X, 24 bytes? I'm using 64-bit machine. C++ makes few guarantees about type sizes and none about the