Problem overloading the addition operator

Pls i'v problems overloading the addition(+) & subtraction(-) operators as i did the multiplication & division operators by declaring them as friend functions within my class definition.
It's actually a matrix class. I'm using visual studio 6.0. Also after compiling, the error window does not show any comprehensive detail on the error. I'll be grateful for your help.
Below is the code
//my class def
class matrix{
friend matrix operator+(const matrix&, const matrix&);
public:
void setmatrix();
void print();
//constructor & other function codes
private:
int matrixx[100][100];
int numcols;
int numrows;
//other member data
}

//operator function implementation
matrix operator+(const matrix& x, const matrix& y){
matrix z;
for(int i=0; i<x.numrows; i++)
for(int j=0; j<x.nuncols; j++)
z.matrixx[i][j] = x.matrixx[i][j] + y.matrixx[i][j];
return z;
}

//main prog
int main(){
matrix a, b;
a.setmatrix();
b.setmatrix();
(a + b).print();
}
//it works well if i replace + with *
You are missing a semicolon after the class closing brace, a typo in for(int j=0; j<x.nuncols; j++)
Topic archived. No new replies allowed.