C++ 如何初始化三维矩阵c++;
我不知道如何初始化3d矩阵 这是终端类的3d矩阵: 这就是康德级水电站: 这就是我尝试初始化的方式:C++ 如何初始化三维矩阵c++;,c++,arrays,dynamic,matrix,3d,C++,Arrays,Dynamic,Matrix,3d,我不知道如何初始化3d矩阵 这是终端类的3d矩阵: 这就是康德级水电站: 这就是我尝试初始化的方式: 相信问题就在这里;您的两个构造函数是: contenidor(const string &m, nat l) throw(error); contenidor(const contenidor &u) throw(error); 但是您正在调用\u terminal[x][y]=新上下文[y]正在尝试查找无参数构造函数,contenidor()。创建一个不接受参数的构造函数,或
相信问题就在这里;您的两个构造函数是:
contenidor(const string &m, nat l) throw(error);
contenidor(const contenidor &u) throw(error);
但是您正在调用
\u terminal[x][y]=新上下文[y]
正在尝试查找无参数构造函数,contenidor()
。创建一个不接受参数的构造函数,或者将参数传递给\u terminal[x][y]=新上下文(…此处的一些参数…[y]代码>问题是我有一个不可修改的hpp,我不能添加任何参数构造函数,答案是:
_terminal[x][y]=新上下文(…此处的一些参数…[y];这是不对的
有人能给我一个完整正确的解决方案吗
谢谢。可能的重复我有一个开发所有计算的说明,我不能使用默认构造函数,只有我显示的2个构造函数。新上下文(…此处的一些参数…[y]代码>不是C++中的有效语法。我尝试了{Tea[x] [y] =新的CaleNoDor(……这里的一些参数…)[Y];而且不行,请问辛塔克斯怎么样?
class contenidor {
public:
contenidor(const string &m, nat l) throw(error);
contenidor(const contenidor &u) throw(error);
~contenidor() throw();
private:
string _m;
nat _l;
contenidor _terminal = new contenidor**[n];
for(int x = 0; x < n; ++x) {
_terminal[x] = new contenidor*[m];
for(int y = 0; y < m; ++y) {
_terminal[x][y] = new contenidor[y];
for(int z = 0; z < h; ++z) {
_terminal[x][y][z] = 0;
}
}
}
terminal.cpp: In constructor ‘terminal::terminal(util::nat, util::nat, util::nat, terminal::estrategia)’:
terminal.cpp:33:43: error: no matching function for call to ‘contenidor::contenidor()’
_terminal[x][y] = new contenidor[y];
^
terminal.cpp:33:43: note: candidates are:
In file included from terminal.hpp:9:0,
from terminal.cpp:1:
contenidor.hpp:16:3: note: contenidor::contenidor(const contenidor&)
contenidor(const contenidor &u) throw(error);
^
contenidor.hpp:16:3: note: candidate expects 1 argument, 0 provided
contenidor.hpp:14:3: note: contenidor::contenidor(const string&, util::nat)
contenidor(const string &m, nat l) throw(error);
^
contenidor.hpp:14:3: note: candidate expects 2 arguments, 0 provided
terminal.cpp:35:8: error: ‘array’ was not declared in this scope
array[x][y][z] = 0;
^
contenidor(const string &m, nat l) throw(error);
contenidor(const contenidor &u) throw(error);