Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Template as Parameter

Status
Not open for further replies.

amw1

Programmer
Feb 9, 2005
12
US
I've got a templated matrix class

Matrix< Type, Row, Col>

I've got a method

void class::perform_calculation( Matrix<int, 5, 4> & matrix )
{

Matrix<int, 4, 5> matrix_transposed = matrix.transpose();

... do other stuff ...

}

I get a compiler error telling me that transpose is not a member of Matrix, but it most definitely is. If I pass by value, I don't get the error.

I must be missing something? Anyone know?
 
Strangely enough, if I move "transpose" to be the first function in the template, I don't get this error.

However, I am also getting the same error on:

matrix_transposed.setAllElements(0);

If I make setAllElements the first element in the class, I don't get this error but I do get the one on the transpose function.

Seems less like a parameter issue and more an issue with the template itself. Any suggestions welcome.
 
Is your template declaration & definition in one file, or are they split into .h and .cpp files?
 
The template is contained within the .h file.
 
Is the template small enough to post? I can't think of much else without seeing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top