Chapter 13. Creating and Using Function Pointers

  • Understand how a function can have a pointer

  • See why pointers to functions can be valuable

  • Create function pointer data types

  • Declare and use function pointers

  • Create arrays of function pointers


How Can a Function Have a Pointer?

When a function is compiled into an executable program, storage is reserved for the function’s executable code to reside in memory at runtime. When the program runs, the function loads into memory somewhere. The address marking the beginning of the function in memory is called the function address.

Function Address

A function address is the memory location marking the starting address of the memory segment that a function’s executable code loads into at runtime. ...

Get Practical C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.