The code describes two classes that implement callback function, the function must should be member function in the class parameter that passed in template. Below the code i attached the relevent error message i get.
a.h
template <class CLASSNAME>
class a
{
public:
typedef void (CLASSNAME::*myFunction)();
a(CLASSNAME& myObject, myFunction callback) :
m_myObject(myObject)
{
m_myFuntion = callback;
}
void update()
{
(m_myObject).*(m_myFuntion);
}
myFunction m_myFuntion;
CLASSNAME& m_myObject;
};
dummy.h
#include <stdio.h>
class dummy
{
public:
dummy()
{
var = 14;
}
void func()
{
printf("func!!");
}
int var;
};
main.cpp
#include <cstdlib>
#include "a.h"
#include "dummy.h"
void main()
{
dummy dum;
a<dummy> avar(dum, &(dummy::func));
avar.update();
system("pause");
}
i am trying to implement the callback function and i get the following error message:
C2298 missing call to bound pointer to member function
what the problem is?