i have searched a little information about "callback function",but i think i didn't understand the true meaning of that.And i write some code to practice.
Here is the code
void *callbackfunction(int m1,void*d1)
{
cout<<"called CBF() "<<m1<<endl;
return (void*) callbackfunction;
}
void accpt(int m1,void*m2(int m3,void*d1))
{
char a='a';
m2(m1,&a);
callbackfunction(m1,&a);
cout<<m1<<" "<<endl;
}
void c()
{
void (*callback)(int,void*callbackfunction(int,void*));
callback=accpt;
callback(1, callbackfunction);
}
int main(int argc, const char * argv[])
{
c();
return 0;
}
Is't just simply that make accpt call callbackfunction ,why not just call it ,and do not use function pointer?
m2(m1,&a);
callbackfunction(m1,&a);
Does callback function have else advantage,or my perspective is wrong? pls help me