给出矢量尺寸时出错
Error when giving a vector of vectors it's dimensions
本文关键字:出错 更新时间:2023-10-16
class tablero
{
int filas_; //initialize both ints
int columnas_;
vector < vector < casilla > > casilla_; // a vector of vectors of Casillas
public:
tablero(int filas, int columnas)
// The above is an initialization list
// We initialize casilla_ as a vector of filas vectors of columnas Casillas
{
filas_=filas; //put the rows in the row int
columnas_=columnas; // and the columns in the columns
casilla_ = filas , vector<casilla>(columnas); // and set the dimensions of the vector of vectors.
}
它给了我"与'operator='不匹配"(操作数类型为'std::vector>'和'int')"错误在casilla_= filas,vector(columnas).filas(rows)columnas(columns)。
我认为一切都很好,但我真的不知道为什么会出现此错误。在 Tablero.h 中,我的构造函数是:
class Tablero {
public:
Tablero(int filas,int columnas); //I added both ints because I had an error in the main.
virtual ~Tablero();
void setcol(int n); //other methods
void setfilas(int n);
vector<vector<casilla> > getCasilla();
void setCasillac(int n ,int t, casilla c);
casilla getCasillac(int n ,int t);
};
如果你需要类卡西利亚和其他东西,只要说出来,我会发布它。我是 c++ 和 eclipse 的新手,我习惯了 Netbeans 和 Java,我不知道如何处理这些例外。
感谢任何可以帮助我的人,当然,如果你需要更多的代码,说出来,我会编辑这篇文章并放进去。
错误告诉您无法将 int 分配给向量:
用:cassilla_.储备(丝虫) ;向量(列) ;
或者使用指向这些的指针并在构造时传入值。
相关文章:
- 访问者访问变体并返回不同类型时出错
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 在Google Kick start中提交时出错
- 在c++中访问int到类对象的映射时出错
- 分段错误当我试图运行程序时出错
- 使用dynamic_cast和构造函数时出错
- CHECK(调用)函数在Google Colab中出错
- 用pybind11包装C++抽象类时出错
- 为x86而非x64编译时出错
- 从R调用C++函数并对其进行集成时出错
- 这个函数哪里出错了
- C++ 创建包含链表和字符串的对象的链接列表时出错
- 为重写std::exception的库生成swig接口时出错
- 导入/导出变量时出错
- PrintWindow函数在notepad.exe中出错