On my MS VS 2015 compiler, the sizeof
int
is 4 (bytes). But the sizeof
vector<int>
is 16. As far as I know, a vector is like an empty box when it's not initialized yet, so why is it 16? And why 16 and not another number?
Furthermore, if we have vector<int> v(25);
and then initialize it with int numbers, then still the size of v
is 16 although it has 25 int
numbers! The size of each int
is 4 so the sizeof
v
should then be 25*4 bytes seemingly but in effect, it is still 16! Why?