|
|
Use of a pointer to a function provides an elegant solution to
some problems.
A pointer to a function holds the memory address of the
function's executable code
Using (dereferencing) the pointer is the same as calling the
function.
Function pointers can only be used in the following way:
* assignment to(specify function name)
* assignment from(make a copy)
* dereference(that is, make function call)
Consider the prototype for some function (here display):
we can declare the existence of a function pointer fptr:
The general form of the syntax is:
Initialize the pointer by simply assigning the name to it.
|
|