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];//这里会
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 17:29:24
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];//这里会
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 **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];//这里会
1) Matrix是一个成员变量,你不需要在allocMatrix中返回,也不需要在releaseMatrix中输入,这是基本的OO概念
2) n是allocMatrix的参数,没有道理再输入一次,你需要把cin>>n删除
3) Matrix在使用之前没有分配内存