Link to home
Start Free TrialLog in
Avatar of Zircona
Zircona

asked on

Callback function

in one of my method i must use a callback function.
the functin is passed like a pointer, how i can use them
Register(void *CallbackFunction,char *name)
{
  i =  (CallbackFunction*)(name,Number);??
}
ASKER CERTIFIED SOLUTION
Avatar of AdrianBrown
AdrianBrown

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

For greater programmer ease and safety, you might want to use virtual functions instead of function pointers.  There is no need for funciton pointers in C++ (unless the project must interface with non-C++ code, like the OS.)
I just want to echo wnat nietod has said.  For those of you who want to write more object oriented code, when you come across a need for a function pointer -- step back and think about the problem and you'll see that a virtual function will fit the bill very nicely.
OK, could you pls give me an example how do you write the AdrianBrown code (see on top of the page) by using virtual functions?
thanks in advance
Sergio