數組我有一個類無法初始化拷貝構造函數
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