Chapter 3. Operators

Another concept in C++ that is fundamental to all programs is the concept of expression. Data variables and literals—presented in Chapter 2, “Data”—form the simplest expressions. By using operators, you can build ever-larger expressions out of simpler ones, like an engineer building ever-more sophisticated parts and engines out of smaller ones.

A typical action in C++ is to calculate a value by evaluating a complex expression.

fahrenheit = (centigrade * 1.8) + 32.0;

The items to the right of the equal sign (=) form a complex expression joining centigrade, 1.8, and 32.0 together with the multiply and addition operators (* and +). The results are then assigned to the variable named fahrenheit. Assignment (=) is itself an expression, ...

Get C++ for the Impatient 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.