I'm trying to overload a operator + to add two arrays. I stacked when I try add two arrays (one copy).
class A{
int *const e;
const int row, column;
public:
A::A(int r, int c) : row(r), column(c), e(new int[r*c])
{
for (int i = 0; i < r*c; i++)
{
e[i] = 0;
}
}
virtual A operator+(const A& a)const
{
A copy = *this;
for (int i = 0; i < copy.row*copy.column; i++)
{
//copy.e
}
return (copy);
}
virtual int *const operator[ ](int r) //get the address of the 1st element of row r
{
return &e[r*row];
}
}
But I cant figure out how to end add two arrays.