A function pointer is a pointer that holds the address of a function. Being able to create pointers to point to functions is awesome but also terrifying, in a way. The great thing about function pointers is that they provide us with a means for executing functions in an order that may not be known at compile time and without needing conditional statements. Function pointers provide support for alternate execution paths.
To declare a function pointer, we surround the function name with parentheses and add an asterisk to the front of the name. A rough outline of a function pointer follows the form return_type (*function_name)(parameters).The asterisk indicates that it is a pointer, and the parentheses make it a function pointer.
//returns void no parameters void (*funcPtrOne)(); //returns int, passed an int int (*funcPtrTwo)(int) //returns double, passed two ints double (*funcPtrThree)(int, int); //returns…
View original post 753 more words