I keep getting an error when trying to use a matrix class someone else wrote about 10 years ago in VC++ 6.0:

Optimizer.cpp:48: error: no matching function for call to 'matrix<double>::matrix(matrix<double>)'

Matrix.h:16: note: candidates are: matrix<T>::matrix(matrix<T>&) [with T = double]

The following is the code with most of the irrelevant stuff removed.

The matrix function definition looks like this:

Code:

template<class T>
matrix<T>::matrix(matrix<T> &x)
{
}

Matrix also has this overloaded operator:

Code:

template<class T>
matrix<T> &matrix<T>::operator=(matrix<T> &x)
{
}

The definition of testPredictor looks like this:

Code:

matrix<double> Predictor::testPredictor(matrix<double> _testX)
{
matrix<double> predictY;
return predictY;
}

The actual line of code where the error trips is:

Code:

matrix<double> trainPredictY = testPredictor(trainX);

where trainX is defined in the header as:

Code:

matrix<double> trainX;

Making it

Code:

matrix<T>::matrix(const matrix<T> &x)

gives me this error:

Matrix.cpp:47: error: passing 'const matrix<double>' as 'this' argument of 'vect<T> matrix<T>::get_row(int) [with T = double]' discards qualifiers

Making it

Code:

matrix<double> trainPredictY( testPredictor(trainX) );

gives me this error:

Optimizer.cpp:48: error: no matching function for call to 'matrix<double>::matrix(matrix<double>)'

Matrix.h:16: note: candidates are: matrix<T>::matrix(matrix<T>&) [with T = double]

Matrix.h:15: note: matrix<T>::matrix(int, int) [with T = double]

Matrix.h:14: note: matrix<T>::matrix() [with T = double]

Any ideas? Thanks.