我上课了
class TTable
{
private:
std::string tableName;
public:
TRow rows[10]; //this other class TRow
TTable(const TTable&);
int countRows = 0;
};
Run Code Online (Sandbox Code Playgroud)
我实现了复制构造函数
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];
}
}
Run Code Online (Sandbox Code Playgroud)
但编译器会对此进行诅咒rows(table.rows).如何初始化数组?随着变量一切顺利,一切都很好.谢谢.