Well... pointers to functions are used in 'callback' functions. Wherein another section of code has to make a call backwards to some notifier function that is not neccesarily known at design time.
This is used for event driven programming. You can have the OS 'call back' a function in your program that you specify whenever a certain action happens. (e.g. data is received on a TCP/IP socket)
Also, to point to a member function, you basically need to get a pointer to the object containing the function as well. So you call the callback function pointer like any other function pointer, but you also call (MyObjectType*)(my_objectPointer)->FunctionPointer();
Thats how its done in C++.
__________________ Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache) |