-
pointers to functions
all books i've seen so far mention briefly pointers to functions in the advanced section, but i havent seen any usefull examples of them that doesnt complecate thins more than doing it the convensional way.
are they used at all in professional programming? if so, do you know of any links to good examples that i can see?
thanks
null
-
They can be used to decide what function is to be used at runtime. If you want to pass a function into a function (eg qsort()) then the function will have to accept an address of a function (a function pointer).
They are used in 'callback' routines where you pass an address of a function so that it can be called when an event happens (so that the event may be handled differently depending on the function used).
-
hi zen. thanx for the info. i'm looking into it now...
found a cool link if anyone cares:
http://www.newty.de/CCPP/FPT/em_fpt.html
or
http://www.function-pointer.org/
regards
null
-
virtual functions
It is also the way that virtual functions are implemented in C++. This goes along with what somebody else said about choosing which function is executed at runtime.