首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

value_type容器中存放元素的类型。vector<int> Vec;Vec:value_type i;该如何处理

2012-03-30 
value_type容器中存放元素的类型。vectorint VecVec::value_type ivectorint VecVec::value_type i

value_type容器中存放元素的类型。vector<int> Vec;Vec::value_type i;
vector<int> Vec;
Vec::value_type i; 请问这种用法为什么不正确,我想用容器元素类型来定义一个变量i

[解决办法]
template<class T> struct Trait{
typedef typename T::value_type value_type;
};

Trait<vector<int> >::value_type i;

热点排行