Main Menu

Sponsored Links


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

Boolean Variables

As usual, for every type of value, there is a corresponding type of variable. In C++ the boolean type is called bool . Boolean variables work just like the other types:

bool bStore;

bStore = true;

bool bTestResult = false;

The first line is a simple variable declaration; the second line is an assignment, and the third line is a combination of a declaration and as assignment, called an initialization.

As I mentioned, the result of a comparison operator is a boolean, so you can store it in a bool variable:

bool bEvenFlag = ( iN % 2 == 0 ); // true if iN is even

bool bPositiveFlag = ( dX > 0 ); // true if dX is positive

and then use it as part of a conditional statement later:

if ( bEvenFlag)


ShowText ( "iN was even when I checked it" );


A variable used in this way is called a flag, since it flags the presence or absence of some condition.

Note: As with the char type, boolean variables are actually stored as integers, 0 for false and 1 for true. It is not recommended to use other than boolean operators on these variables, however, because the results may be unpredictable.

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