matrix.h
#pragma once
#ifndef __MATRIX_BASE__
#define __MATRIX_BASE__
#include <iostream>
#include <vector>
using namespace std;
class Matrix {
public:
Matrix() {};
Matrix(int row, int col);
Matrix(const Matrix &A);
~Matrix() {};
void print(int row);
void init(){
array.resize(_row);
array[0].resize(_col);
}
//运算符重载
Matrix& operator + (const Matrix& rhs);
Matrix& operator = (const Matrix& rhs);
void add_row_element(int nrow, vector<double> vec);
private:
int _row;
int _col;
vector<vector<double>> array;
};
#endif // !__MATRIX_BASE__
matrix.cpp
Matrix::Matrix(int row, int col)
{
if (row < 0 || col < 0){
cout << "Row or col must b