how can we add two matrices in the example given below?

class Matrix1
{

Protected:
int ** data;
int row,col;
Public:

};
Class Matrix2 : Public Matrix
{
Public:
Matrix2()
{

}
Matrix2 (int a, int b):Matrix1(a,b)
{

}
void resize()
{

//?????

}

};
// can we do this in our driver/main file(function) i.e.
Matrix2 m1(3,4);
Matrix2 m2(3,4);
Matrix m=m1+m2;
// is this legal ? if yes, then how will it work ?
I think that this

Class Matrix2 : Public Matrix

is a typo. Should be

Class Matrix2 : Public Matrix1


However I do not understand why is derived class used?
See:

Matrix addition
http://en.wikipedia.org/wiki/Matrix_addition

Andy

PS And see

How to use code tags
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Topic archived. No new replies allowed.