如何将程序拆分为文件C 类
How to split program into files- class c++
我现在有点困惑,我正在尝试将程序拆分为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)
我知道它不会这样起作用,但是我尝试了许多其他解决方案,但没有结果,因此请感谢您对初学者的任何提示/建议。
在包含类的外部声明嵌套类时,您必须使用其全名 class matrix::rcmatrix
。
否则,编译器认为您想声明另一个完全分开的班级。
相关文章:
- 如何拆分文件中.txt字母并使用c ++使用数组进行扑克?
- C++(.cpp文件和.h文件)拆分代码并添加一个函数,提取 - 这很容易吗?
- 如何在拆分为多个文件的分层 SM 中退出子机器?(使用boost::MSM)
- 如何通过在逗号处拆分将文件读入 2D 列表
- 读取行文本文件,如果它得到逗号,则拆分
- 将 c++ 代码拆分为多个文件
- 从文件中逐块读取,然后逐行拆分测试
- 如何使用 c++ 逐行处理文本文件并将其参数拆分为变量?
- C++ 将类拆分为多个文件.当我指定类型时假定显式类型 int
- 如何将程序拆分为文件C 类
- 从文件中获取字符串并将其拆分
- C++强力球 - 文件拆分和错误(游戏类型)
- 按代码 c 拆分文件时出错
- 分析示例文本文件并将其拆分
- 如何将XML文件拆分为多个XML,以便每个新文件只包含原始文件中的一个文本节点
- 将大型数据文件拆分为多个小文件(文本格式)
- 将文本文件拆分为多个文件 c++
- 将一个文件拆分为多个文件
- 我应该始终将文件拆分为声明(.h)和定义(.cpp)吗
- 如何将数据文件拆分为多个部分