Main Menu

Sponsored Links


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

Functions with Results

So far we have only discussed functions preceded by the key word void , which means the function does not return a value to the calling program. In WCM, this is the most common case, however in general there are many functions which return a value to the calling program.

You might have noticed by now that some of the functions we are using, like the math functions, yield results. Other functions, like ShowTextTwice, perform an action but don’t return a value. That raises some questions:

  1. What happens if you call a function and you don’t do anything with the result (i.e. you don’t assign it to a variable or use it as part of a larger expression)?

  2. What happens if you use a function without a result as part of an expression, like ShowTextTwice () + 7?

  3. Can we write functions that yield results, or are we stuck with things like ShowTextTwice?

The answer to the third question is “yes, you can write functions that return values,” and we’ll do it in a couple of chapters. I will leave it up to you to answer the other two questions by trying them out. Any time you have a question about what is legal or illegal in C++, a good way to find out is to ask the compiler.

Note: Though beyond the scope of this book, the first question can be important in general C++ programming. All C++ programs must have a main program which usually has the form:

void main ()



However in some cases, the main program may receive or supply information to the computer’s operating system (OS). Thus, if this feature is to be used, the programmer must not only understand C++ but have a basic understanding of the OS as well. Fortunately for the novice, this is a relatively rare occurrence but you should be aware the possibility exists.

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...