我写了这段代码:
#include<vector>
using namespace std;
int i;
int j;
cin>>i>>j;
vector<vector<vector<vector<double> > > > boy_max(i,vector<double>(i,vector<double>(j,vector<double>(j,0))));
在编译过程中出现以下错误:
prog.cpp: In function ‘int main()’:
prog.cpp:164: error: no matching function for call to ‘std::vector<double, std::allocator<double> >::vector(int&, std::vector<double, std::allocator<double> >)’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:247: note: candidates are: std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = double, _Alloc = std::allocator<double>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:234: note: std::vector<_Tp, _Alloc>::vector(size_t, const _Tp&, const _Alloc&) [with _Tp = double, _Alloc = std::allocator<double>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:221: note: std::vector<_Tp, _Alloc>::vector(const _Alloc&) [with _Tp = double, _Alloc = std::allocator<double>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_vector.h:213: note: std::vector<_Tp, _Alloc>::vector() [with _Tp = double, _Alloc = std::allocator<double>]
答案 0 :(得分:1)
您的初始化行错误。应该更像这样:
vector<vector<vector<vector<double> > > > boy_max(i,vector<vector<vector<double> > >(i,vector<vector<double> >(j,vector<double>(j,0))));