【发布时间】:2017-01-01 21:54:49
【问题描述】:
伙计们,我现在有点困惑,我正在尝试将程序拆分为 file.h file.cpp 和 main.cpp,这是我的代码示例:
//file.h//
class matrix
{
private:
class rcmatrix;
rcmatrix *data;
public:
class Cref;
class Size_Check{};
matrix();
~matrix();
matrix(const int rows, const int cols, const double num);
};
class rcmatrix
{
private:
rcmatrix(const rcmatrix&);
rcmatrix &operator =(const rcmatrix&);
public:
int rows;
int cols;
double **mat;
int n;
rcmatrix();
~rcmatrix();
};
//file.cpp
matrix::rcmatrix::rcmatrix()
{
rows=0;
cols=0;
mat=NULL;
n=1;
};
matrix::rcmatrix::rcmatrix(const int r, const int c, const double num)
{
//instructions.
};
我收到以下错误:
error: invalid use of incomplete type ‘class matrix::rcmatrix’
error: ‘class matrix::rcmatrix’ is private
error: expected unqualified-id before ‘const’
matrix::rcmatrix(const int r, const int c, const double num)
我知道它不会以这种方式工作,但我尝试了许多其他解决方案但没有结果,因此感谢 C++ 初学者的任何提示/建议。
【问题讨论】:
-
(a) 您是否已经将程序放在一个大文件中,然后尝试拆分它,还是已经拆分? (b) 错误发生在哪几行?