Hi all,
Can any one explain me what is callback function....
I have written some code after reading some tutorials from internet...
But I am not sure is it a right way to write a call back function...
I have mentioned my doubts in code comments.
My code is...
void myfun_callback(void(*fp)(char*)) //is this function is a call
back?
{
(*fp)("Pradeep Kumar");
}
void A(char *msg) //function A,called by myfun_callback
{
cout<<"Function A: "<<msg<<endl;
}
void B(char *msg) //function A,called by myfun_callback
{
cout<<"Function B: "<<msg<<endl;
}
int main()
{
void(*fp)(char*); //function pointer
fp=A; //giving address of function A
myfun(fp); //right way to call the callback function?
fp=B; //giving address of function B
myfun(fp); //right way to call the callback function?
return 0;
}
ur help will be appreciated..
Thank u in advance
Regards
Pradeep Kumar Basrani