b******w 发帖数: 52 | 1 I am a little confused about the sizeof(string) = 4.
Since string is a specialized basic_string, and basic_string is derived
from _String_base.
_String_base has three protected pointers:
_Tp* _M_start;
_Tp* _M_finish;
_Tp* _M_end_of_storage;
thus sizeof(string) should be 12 instead of 4?
is there anybody to elaborate on this?
template
class _Traits = char_traits<_CharT>,
class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) >
class basic_string;
typedef basic_ | X****r 发帖数: 3557 | 2 You were not looking at the actual code that you were compiling.
Try to find the actual string header file in your system, and you'll see.
【在 b******w 的大作中提到】 : I am a little confused about the sizeof(string) = 4. : Since string is a specialized basic_string, and basic_string is derived : from _String_base. : _String_base has three protected pointers: : _Tp* _M_start; : _Tp* _M_finish; : _Tp* _M_end_of_storage; : thus sizeof(string) should be 12 instead of 4? : is there anybody to elaborate on this? : template
| b******w 发帖数: 52 | 3 My fault.
thanks.
【在 X****r 的大作中提到】 : You were not looking at the actual code that you were compiling. : Try to find the actual string header file in your system, and you'll see.
|
|