Chapter 13. Creating and Using Function Pointers

<feature>
  • 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

</feature>

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.