理解vector<T>::size_type类型
2013-10-07 15:01
337 查看
size_type是无符号类型,通常是unsigned,定义在类里是一种设计要求
补充:
int有符号,size_type无符号,但长度一般一样(注意是一般),基于类的实现封装为考虑,推荐使用vector<int>::size_type,这样可以提高代码的兼容性,否则如果有一天库的作者把size_type定义为:
typedef other_type size_type; // 只是个假设
原来的代码中如果int不兼容other_type,就要出问题了
补充:
int有符号,size_type无符号,但长度一般一样(注意是一般),基于类的实现封装为考虑,推荐使用vector<int>::size_type,这样可以提高代码的兼容性,否则如果有一天库的作者把size_type定义为:
typedef other_type size_type; // 只是个假设
原来的代码中如果int不兼容other_type,就要出问题了
相关文章推荐
- vector<int>::size_type 解释
- vector<string>::size_type与string::size_type
- std::vector<std::string>::size_type和 int的区别
- C++基础<04>—标准库vector类型
- vector<IplImage*>类型时push_back问题
- Mat, vector<point2f>,Iplimage等等常见类型转换
- 关于用创建vector<type> name类型的一维数组(vector<type> name[])来存储图(邻接表法储存)
- Mat, vector<point2f>,Iplimage等等常见类型转换
- C++类型转换运算符之const_cast<newtype>(expression)
- 深入理解泛型,类型通配符<?>,类型通配符上限,下限
- <input type="file" />浏览时只显示指定文件类型
- c++ vector<vector<int>>b(a[0].size(),vector<int>(a.size()))
- C++ vector<int>::size_type的使用
- <input type="file" />浏览时只显示指定文件类型
- 深层次理解JNI中的GetArray<PrimitiveType>Elements()函数
- c++ vector<int>v v.size()
- vector排序问题<unresolved overloaded function type>
- C++类型转换关键字 *_cast<type> (expression)
- <input type="file">定义样式并获取上传文件路径及指定文件类型
- HTML <script>标签的type类型