相关疑难解决方法(0)

在STL容器中使用value_type有什么用?

什么是使用value_type在STL容器?

来自MSDN:

// vector_value_type.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   vector<int>::value_type AnInt;
   AnInt = 44;
   cout << AnInt << endl;
}
Run Code Online (Sandbox Code Playgroud)

我不明白value_type这里具体实现了什么?变量也可以是一个int?是否使用是因为编码人员懒得检查向量中存在的对象类型是什么?

一旦我清楚这一点,我想我能理解allocator_type,size_type,difference_type,reference,key_type等.

c++ stl

8
推荐指数
1
解决办法
3152
查看次数

标签 统计

c++ ×1

stl ×1