数组我有一个类无法初始化拷贝构造函数
class TTable
{
private:
std::string tableName;
public:
TRow rows[10]; //this other class TRow
TTable(const TTable&);
int countRows = 0;
};
我实现了拷贝构造函数
TTable::TTable(const TTable& table) : tableName(table.tableName), countRows(table.countRows), rows(table.rows)
{
cout << "Copy constructor for: " << table.GetName() << endl;
tableName = table.GetName() + "(copy)";
countRows = table.countRows;
for (int i = 0; i < 10; i++)
{
rows[i] = table.rows[i];
}
}
但是,编译诅咒这个rows(table.rows)
。如何初始化一个数组?随着变量的发展,一切都很好。谢谢。
std :: array行中的错误;未完成类型 –
Xom9ik
使用'#include'并确保'TRow'在使用之前进行竞争性声明。 –
user0042
谢谢。这就是我需要的 – Xom9ik