RAD Studio |  |

Pointers To Functions

A pointer to a function is best thought of as an address, usually in a code segment, where that function's executable code is stored; that is, the address to which control is transferred when that function is called.

A pointer to a function has a type called "pointer to function returning type," where type is the function’s return type. For example,

Copy Code

    void (*func)();

In C++, this is a pointer to a function taking no arguments, and returning void. In C, it's a pointer to a function taking an unspecified number of arguments and returning void. In this example,

Copy Code

    void (*func)(int);

*func is a pointer to a function taking an int argument and returning void.

For C++, such a pointer can be used to access static member functions. Pointers to class members must use pointer-to-member operators. See static_cast for details.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!