菜鸟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 );