Statements and Expressions
In C++, unlike in other languages, the difference between an expression and an executable statement is quite small: Any expression can be converted to a statement by appending it with a semicolon. Here are some examples of expressions and executable statements.
x * y // valid expression that can be used in other expressions x * y; // valid statement in C++, but quite useless a = x * y // valid expression that can be used in others (do it with caution) a = x * y; // valid C++ statement, useful and common x++ // valid expression that can be used in others (do it with caution) x++; // valid C++ statement, common and useful foo() // call to a function returning a value (a valid expression) foo(); // call to a function ...
Get Core C++ A Software Engineering Approach 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.