Function pointers are a very good type. Therefore, you can compile a function. One of its parameters is the function pointer. Then, when the (external) function uses its function pointer parameter, it indirectly calls the function that the corresponding parameter points to when calling the function.
Since pointers can point to different functions under different circumstances, the caller is allowed to determine which function to call from an external function.
When calling a function with a function pointer type parameter, the parameter can only contain the corresponding type pointer of the function address. You can also use the function name as a parameter to display the transfer function. A function that is transmitted as a parameter to another function is sometimes called a callback function.
Example:
# Include
Using std: cout; using std: endl; // function declaration double squared (double); double cubed (double); double sum_array (double array [], int len, double (* pfun) (double); int main () {double array [] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5 }; int len = sizeof array/sizeof array [0]; cout <"Sum of squares =" <