I already implemented successfully by use of std::bind and function object.But i want to do with function pointer. I am not able to do with funtion pointer, facing problem while registering call back.
class A{ public: int id; A(){}; typedef void(*fptr_t)(void); // function pointer fptr_t f1=NULL; void operator()(int i) //using functors
{ id=i; cout<<"Object number "<
void call_bk_handler(fptr_t fp)
{
f1= fp;
}
......... };
class B {
public:
B(int N):baseObj(N),m_total_clicks(0),m_clicks(N,0)
{
for(int i=0;i<N;i++)
{
A[i](i); // using functors;
A[i].call_bk_handler(&B::callBack); // this is not working
}
void callBack(){ ............. };
} std::vectorbasedObj; public: int m_total_clicks;
std::vector<int>m_clicks;
int count=0;
Aucun commentaire:
Enregistrer un commentaire