vector - 初始化4D向量

我写了这段代码:

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

最佳答案

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

vector<vector<vector<vector<double> > > > boy_max(i,vector<vector<vector<double> > >(i,vector<vector<double> >(j,vector<double>(j,0))));

https://stackoverflow.com/questions/13218318/

相关文章:

compiler-errors - 免费的基本编译器错误23 : File not found, l

compiler-errors - 我的部分产品生成器出了什么问题

wpf - WPF,将XAML文件移动到另一个项目

c# - 编译委托(delegate)和调度程序时出错

sorting - "nonL value in assignment "错误 C++对链表进行排序

c# - asp.net代码显示编译器错误消息: CS1729: 'EmailReader.Pop3

compiler-errors - IPv4和IPv6地址的lex模式

compiler-errors - 带有C++/CLI的VS2012中的错误C2039错误

qt - Qwt和Boost::signals

compiler-errors - 如何使Groovy Shell读取#符号