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

Functions

While main() is a function, it is an unusual one, because it is called automatically when you start your program. All other functions are called by your own code as the program runs.

A program is run line by line starting at the top of main, until another function is called. Control is then transferred to that function. When that function finishes, it returns control to the line after its call in main. If the function you call in turn calls another function, control flows in the same way—returning to the line in the first function that follows its call to the other function.

Even if a function is defined above main in the listing (you'll see this later), it is not performed before main. main always runs first.

Functions either return ...

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