+ 6
Do you use pointers to functions ?
Are they useful or not ? I can't find a good usage for them. May be you can show a really needed example for them.
15 Respuestas
+ 13
They are used for callback functions, which are defined by users of certain classes/API.
+ 7
Also virtual functions are implemented with function pointers...that's how you get runtime polymorphism.
+ 4
it's also used to save links in creating linked lists
+ 4
Yes, but not a lot.
+ 3
The first thing that comes to my mind as a very useful application is a button. Take the following code:
int buttonID = CreateButton ("Click Me!", 100, 100, 200, 100, onClick);
This would create a button at (100,100) with width 200 and height 100. Every time you click it, onClick is called.
I use something similar in a personal Windows API wrapper. It makes creating buttons etc so much easier.
+ 2
for a newbie like me, i used it for (easy to read) my own code.. because i want to differentiate some instructions into a function and i need the value from the function..
+ 1
yes..it keeps the address of other function or variable
+ 1
yes
+ 1
it is just one of the concepts in c++.it is used just to enhance the efficiency of the program
+ 1
It keeps the address of other variable or array
+ 1
yes... they help us to point towards an address which is stored in a variable
+ 1
pointers in functions are actually required in arrays as sometimes you cant actually pass the array to the function
0
yes. the pointers to functions are useful to handle multiple functions with same return type
0
yes
0
pointer function is use to address a variable in the program