M
mickey
I have the following template class which I use as a c++ generic callback.
template< class T >
class CallBack
{
public:
typedef void ( T::*Method )( void );
CallBack( void ) : m_classInstance( NULL ), m_method( NULL ){}
CallBack( T* classInstance, Method method ) : m_classInstance(
classInstance ), m_method( method ){}
void operator()( void ) const
{
if( m_classInstance != NULL && m_method != NULL )
( m_classInstance->*m_method )();
};
private:
T* m_classInstance;
Method m_method;
};
I have another class which has a method that takes a template class as a
param...
class foo
{
public:
foo( void );
template< class T >
const boolean Load( CallBack< T > const& callBack, const int16
imgResID )
{
return TRUE;
}
CallBack<class T> m_callback; // member I would like to assign the
callback refernce to
}
I would like class foo to have a member to which I can assign the
callback reference passed in the Load method.
My problem is that the compiler complains about the difference in types
between m_callback and the callback param. I am not sure how to declare
the m_callback.
Thanks.
template< class T >
class CallBack
{
public:
typedef void ( T::*Method )( void );
CallBack( void ) : m_classInstance( NULL ), m_method( NULL ){}
CallBack( T* classInstance, Method method ) : m_classInstance(
classInstance ), m_method( method ){}
void operator()( void ) const
{
if( m_classInstance != NULL && m_method != NULL )
( m_classInstance->*m_method )();
};
private:
T* m_classInstance;
Method m_method;
};
I have another class which has a method that takes a template class as a
param...
class foo
{
public:
foo( void );
template< class T >
const boolean Load( CallBack< T > const& callBack, const int16
imgResID )
{
return TRUE;
}
CallBack<class T> m_callback; // member I would like to assign the
callback refernce to
}
I would like class foo to have a member to which I can assign the
callback reference passed in the Load method.
My problem is that the compiler complains about the difference in types
between m_callback and the callback param. I am not sure how to declare
the m_callback.
Thanks.