O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND 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

Nesting Parentheses

With complex expressions, you might need to nest parentheses (to put a subexpression inside another subexpression). For example:

4*(3+(6/2))

This complicated expression should be read from the inside out. First, divide 6 by 2. Then add 3 to that result. Then multiply the updated result by 4.

Because C++ doesn't require an expression to be written on a single line, you can make this more understandable by using the parentheses as if they were braces:

4*
(
   3+
   (6/2)
)

This makes it easier to be sure that every opening parenthesis has a closing parenthesis (thus avoiding a common programming mistake).

Expressions in cout

iostream can display the result of a complex expression just as easily as it can display a simple string ...

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