O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Expressions

Any statement that returns a value is an expression in C++.

There it is, plain and simple. If it returns a value, it is an expression. All expressions are statements.

The myriad pieces of code that qualify as an expression might surprise you. Here are three examples:

3.2                       // returns the value 3.2
PI                        // float const that returns the value 3.14
SecondsPerMinute          // int const that returns 60

Assuming that PI is a const equal to 3.14 and SecondsPerMinute is a constant equal to 60, all three of these statements are expressions.

The complicated expression

x = a + b;

not only adds a and b and assigns the result to x, but yields the value ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required