Function pointer:
The function pointer must contain the memory address of the function to be called. to work properly, the pointer must also contain other information, that is, the parameter type and return type in the parameter list of the function to which the Pointer Points. Therefore, when declaring a function pointer, you must specify the parameter type, return type, and pointer name of the function that the pointer can point.
The function pointer is generally in the following format:
Return type (* pointer) (parameter type list );
Note: The parentheses on the pointer name are indispensable. Otherwise, * will be combined with the return type to form a function prototype.
Example:
# Include
Using std: cout; using std: endl; // function declaration long sum (long a, long B); long product (long a, long B ); int main (int argc, char * argv []) {// function pointer declaration long (* pfun) (long, long) = 0; // point to the product function pfun = product; cout <