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

初学者vector疑问求解

2012-05-01 
菜鸟vector疑问求解1.C/C++ codevectorvectorint vec//为什么这样写错误(vc6)//下面两种写法就可以ve

菜鸟vector疑问求解

1.

C/C++ code
vector<vector<int>> vec;  //为什么这样写错误(vc6)//下面两种写法就可以vector<vector<int> > vec;vector< vector<int> > vec;


2.
C/C++ code
vector<string> svec("hello");cout<<svec[0]<<endl;   //为什么不能输出,报错太乱看不懂(对模板基本一窍不通)


望不吝赐教,谢了

[解决办法]
vector<vector<int">>" vec;以为那是重载了右移操作符
svec("hello");
vector没有这种构造函数
[解决办法]
1. 编译器bug.
2.vector构造函数列表:
C/C++ code
explicit vector ( const Allocator& = Allocator() );explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );template <class InputIterator>         vector ( InputIterator first, InputIterator last, const Allocator& = Allocator() );vector ( const vector<T,Allocator>& x ); 

热点排行