Functions

Although main() is a function, it is an unusual one. Your operating system invokes main() to start your program. Other functions are called, or invoked, from main() or from one another during the course of your program.

The function main() always returns an int. As you'll see in the coming hours, other functions might return other types of values or might return nothing at all.

A program is executed line by line in the order it appears in your source code, until a function is called. Then the program branches off to execute the function. When the function finishes, it returns control to the line following where the program called the function.

Imagine that you are drawing a picture of yourself. You draw the head, the eyes, the nose, ...

Get Sams Teach Yourself C++ in 24 Hours, Third Edition 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.