June 2025
Intermediate to advanced
1093 pages
33h 24m
English
You can also use any expression as a statement. Although it makes little sense to use 3+4; as a statement, for example, assignments are expressions and are used as statements very often.
Assuming you have previously declared int upTo;, the following listing gives examples of expressions used as statements.
upTo = 99; // an assignment is an expressionupTo = upTo * 2 + 1; // combining an assignment with a calculationcalculatePrimesUpTo(upTo); // a function call is an expressionstd::cout << "Friedrich III"; // the output operator
Listing 8.9 These are all expressions used as statements.
As I mentioned earlier, every expression has a value and a type. If an expression is used as a statement, the type disappears ...
Read now
Unlock full access