为了使本身的程序有很好的移植性,c++程序员应该尽可能使用size_t和size_type而不是int, unsignedc++
size_t是全局定义的类型;size_type是STL类中定义的类型属性,用以保存任意string和vector类对象的长度程序员
string::size_type 制类型通常就是unsigned int, 可是不一样机器环境长度可能不一样 win32 和win64上长度差异;size_type通常也是unsigned int数组
string::size_type a =123; vector<int>size_type b=234; size_t b=456;
size_t 使用的时候头文件须要
sizeof(string::size_type) sizeof(vector<bool>::size_type) sizeof(vector<char>::size_type) sizeof(size_t)
上述长度均相等,长度为win32:4 win64:8