Jump to content
  • Advertisement
Sign in to follow this  
hkBattousai

[C++] Strange error: Prototype and implementation of a method do not match

This topic is 2566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[size=2][size=2][size=2][size=2][size=2][size=2]This is the method whose definition gives compiler error:
// ...

template <class T> class Matrix
{
public:[size=2]
// ...[size=2]

template <class T>
static void SolveAxb( const Matrix<T> & _A,
Matrix<T> & x,
const Matrix<T> & _b)
throw(MatrixInvalidSize, MatrixNotSquare);

// ...
};

// ...

template <class T>
void Matrix<T>::SolveAxb( const Matrix<T> & _A,
Matrix<T> & x,
const Matrix<T> & _b)
throw(MatrixInvalidSize, MatrixNotSquare)
{
// Empty. Contents of the method are commented out.
}

// ...


Compiler error:
error C2244: 'Matrix<T>::SolveAxb' : unable to match function definition to an existing declaration[/quote]

Compiler/IDE: Microsoft Visual Studio 2010


What can be the cause of this error message?
I'm totally stuck at this point.
Any help will be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Is it really your intention to have the SolveAxb function be a sub-template of the templated class Matrix, or do you just want a single instance of SolveAbx for every template-instance of the class Matrix with the same type? At the moment, the Matrix class and the SolveAxb function have two different template parameters, only they are named the same so the one on the SolveAxb function shadows the one on the Matrix class.

If the latter, drop the template on the function declaration.

Share this post


Link to post
Share on other sites
Drop the "template <class T>" at the method declaration.

What you are basically doing is defining a template method inside a template class. If that is intended (which by the loook of your code isn't the case), the template parameter at the method declaration needs to have a different name than the template parameter of the class declaration.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!