O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Function Pointers and Callbacks

Data on the stack has a location—also called an address. So does data on the heap. And so does every line of code in your program. In fact, when you read about “the flow of control,” you should actually think of a variable used by the operating system to keep track of which instruction of the program is being performed. Top-to-bottom control flow is just like moving through an array using an index or pointer.

In fact, a program to run programs might look something like Listing 15.4.

Listing 15.4. Outline of a Program to Run Programs
 1: struct anInstruction 2: { 3: anInstructionCode InstructionCode; 4: anInstruction *NextInstruction; 5: } ; 6: 7: anInstruction *Program = 8: new anInstruction[NumberOfInstructions]; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required