0

我写了这段代码:

 #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>]
4

1 回答 1

1

您的初始化行是错误的。它应该更像这样:

vector<vector<vector<vector<double> > > > boy_max(i,vector<vector<vector<double> > >(i,vector<vector<double> >(j,vector<double>(j,0))));
于 2012-11-04T12:02:04.713 回答