Main Menu

Sponsored Links


Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Programs with Multiple Functions

When you look at a program that contains several functions, it is tempting to read it from top to bottom, but that is likely to be confusing, because that is not the order of execution of the program.

Execution always begins at the first statement of Scene1, regardless of where it is in the program (sometimes it is at the bottom). Statements are executed one at a time, in order, until you reach a function call. Function calls are like a detour in the flow of execution. Instead of going to the next statement, you go to the first line of the called function, execute all the statements there, and then come back and pick up again where you left off.

That sounds simple enough, except that you have to remember that one function can call another. Thus, while we are in the middle of main, we might have to go off and execute the statements in ShowTimeThreeTimes. But while we are executing ShowTimeThreeTimes, we get interrupted three times to go off and execute ShowTime.

Fortunately, C++ is adept at keeping track of where it is, so each time ShowTime completes, the program picks up where it left off in ShowTimeThreeTimes, and eventually gets back to Scene1.

What’s the moral of this sordid tale? When you read a program, don’t read from top to bottom. Instead, follow the flow of execution.

Contents Previous Next

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi


Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat


Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.


Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal


read more news...