I have a class Matrix2D where the matrix is defined as vector<double> elements. I'm trying to use the function Gauss() to perform gaussian elimination on a matrix a

bool Gauss(Matrix2D& a)
{
[INDENT][/INDENT]//Gaussian elimination routine
}

The function itselt works perfectly and if I view the matrix a just before the function ends a is in reduced form.

This routine is being called by a parent class structure() as follows

Gauss(s.getSolMat());

where s.getSolMat() returns the matrix to be solved (return SolMat) and s is an instance of a subclass of structure() and parent of Matrix2D(). The problem is if I view the matrix after this routine has been executed from within structure() it appears as if the Gauss() routine hasn't run. But I know it worked from checking within the function.

For some reason SolMat (the variable returned by s.getSolMat()) is forgetting its value?

Can anyone understand why this isn't working for me?

Thanks

getSolMat() would have to return a reference of Matrix2D.

Matrix2D & structure::getSolMat();

Ah ha... that makes sense!

Thanks for the speedy reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.