Modern C++: The Good Parts/Now it gets interesting.

Up to now all of our programs have been very straightforward: Start at the top and read each line once until you get to the bottom. That changes now, because that's not really a very useful way to write a program. Useful programs usually repeat some things, or decide to not do some. This chapter covers how to select a course of action on the fly.

Explanation
is short for Boolean, which means yes or no, true or false. In this case the bool variable "canDecide" is initialized to the value. Basically, the program assumes it "canDecide" which number is greater, until it sees evidence to the contrary. Overwriting bools in this way can be very useful.

is the equality operator; it determines whether two values are equal, and returns true or false. Note: It does not change the value of anything.

Anything that looks like  is an if statement. is an expression which evaluates to a bool. An expression is some code which can be resolved to a value. The curly brackets just after  contain code which will run if a equals b.

means "Otherwise, if..." and is only tested if the condition (the bool) is false for the first if statement. by itself doesn't test any condition, but only runs if none of the if statements in its chain have been run.

When some logic is selected for execution in this way, "control" is said to "flow" into the logic. So  statements are considered control flow statements or control structures, a set which contains some other constructs to be introduced later.

Exercises

 * Write a calculator, asking the user for two floats and an operator and then printing the result.

Vocabulary

 * bool: one of two possible values,  or  . Also called a condition.
 * expression: some code which can be resolved to a value.
 * if statement: runs if its condition is true. Syntax:
 * control flow: which code runs, and in what order.
 * control structure: a statement which modifies control flow. Also called a control flow statement.