我在用动态数组重载 = 运算符时遇到了麻烦。这就是我到目前为止所拥有的。另外我知道我还没有写我的析构函数或构造函数,但我需要首先关注这个运算符:
在我的头文件中:
#ifndef fasdf_dynn_h
#define fasdf_dynn_h
#include <iostream>
#include <fstream>
#include<string>
#include <cstdlib>
#include <vector>
using namespace std;
template <class T>
class MatrixdynVector{
public:
template <class H>
MatrixdynVector<H>& operator =(const MatrixdynVector<H>& c)
{
if (this == &c)//checks for self assignment
{
return *this;
}
else
{
delete [] matrix;
matrix=new int[c.m*n];
this->m=c.m;
this->n=c.n;
return *this;
}
}
private:
int m,n;
int** matrix;
};
#endif