Réduire
Brouillon
0
11/07/2013
0

Why is sizeof(string) 32 bytes?

Mots-clés:
C++

Because that's the way Microsoft implemented the string class in the compiler library. A string object contains a pointer, a length, a 16-character array, and some other stuff. The easiest way to examine it is to create a string object in your program and then look at it with the debugger. The variable-length content of the string is either in the array or addressed by the pointer. It's not reflected in the size of the string object, which is constant.