Dear All,
I have problem on programming in template class.
Code:
#include <stdio.h>
template <class ArgType>
class ClassA
{
public:
template <class ClsType>
void Func( ClsType* pObj, void (ClsType::*pClsFunc)(ArgType), ArgType arg )
{
(pObj->*pClsFunc)( arg );
}
};
class ClassB
{
public:
void Func( int a )
{
printf( "a=%d\n", a );
}
};
int main( int argc, char* argv[] )
{
ClassA<int> a;
ClassB b;
a.Func( &b, ClassB::Func, 1 );
return 0;
}
while i use g++ to compile the program, i got the following message
test.cpp: In function `int main(int, char**)':
test.cpp:28: no matching function for call to `ClassA<int>::Func(ClassB*,
<unknown type>, int)'
test.cpp:9: candidates are: void ClassA<ArgType>::Func(ClsType*, void
(ClsType::*)(ArgType), ArgType) [with ClsType = ClassB, ArgType = int]
But this program can be successfully compiled in VC++.
Please Help.
Reply me please