我一直在学校的一个项目中工作,该项目给了我一些编译问题,想知道我是否可以再看看我做错的事情,我一直遇到的错误在测试的第47行中文件说操作符* =不匹配,这使我很困惑。我将包括.h(标头)、. cc(实现)和测试文件。
#ifndef MATRIX_H
#define MATRIX_H
#include <iostream>
using namespace std;
class Matrix {
public:
// Construction
Matrix(int, int, double);
// Copy construction
Matrix(const Matrix& m);
// Destructor
~Matrix();
// Index operators
const double& operator()(int i, int j) const; //to work on const objects
double& operator()(int i, int j);
// Copy assignment operator
Matrix& operator=(const Matrix& m);
// Compound arithmetic operators
Matrix& operator+=(const Matrix& x);
Matrix& operator-=(const Matrix& x);
Matrix& operator*=(const Matrix& m);
Matrix& operator*=(double d); // scalar multiplication …Run Code Online (Sandbox Code Playgroud)