tags:

views:

69

answers:

1

consider the following template class.

template <class T>
class MyClass
{
   void MyFunc();
}

template <class T>
void MyClass<T>::MyFunc()
{
  //...implementation goes here
}

I need to add another function MyFunc2 which accepts an additional Template arg T2 i.e

template <class T>
class MyClass
{
   void MyFunc();

   template <class T2>
   static void MyFunc2(T2* data);
}

template <class T>
void MyClass<T>::MyFunc()
{
  //...implementation goes here
}

template <class T, class T2>
void MyClass<T>::MyFunc2(T2* pData)
{
  //...implementation goes here
}

I am using VS 2008 compiler. I am getting the error

error C2244: unable to match function definition to an existing declaration

How should the the functions definition and declaration look like in this case.

+10  A: 
template <class T>
template <class T2> 
void MyClass<T>::MyFunc2(T2* pData) 
{ 
  //...implementation goes here 
}

EDIT 2:

$14.5.2/1 - "A template can be declared within a class or class template; such a template is called a member template. A member template can be defined within or outside its class definition or class template definition. A member template of a class template that is defined outside of its class template definition shall be specified with the template-parameters of the class template followed by the template-parameters of the member template."

Chubsdad
I've always found this syntax awkward, it doesn't get better with nested classes either...
Matthieu M.