作业帮 > 综合 > 作业

C++矩阵错误class Demo{public:\x05Demo();\x05~Demo();\x05double *

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/09/29 23:27:18
C++矩阵错误
class Demo
{
public:
\x05Demo();
\x05~Demo();
\x05double **allocMatrix(int n);
\x05void releaseMatrix(double **m);
private:
\x05double **Matrix;
};
double Demo::**allocMatrix(int n)
{
\x05cin >> n;
\x05
\x05for (int i = 0; i Matrix[i][j];//这里会报错,
\x05\x05\x05cout
C++矩阵错误class Demo{public:\x05Demo();\x05~Demo();\x05double *
1) Matrix是一个成员变量,你不需要在allocMatrix中返回,也不需要在releaseMatrix中输入,这是基本的OO概念
2) n是allocMatrix的参数,没有道理再输入一次,你需要把cin>>n删除
3) Matrix在使用之前没有分配内存