Chapter 2. Syntax

C++ has a complex syntactic and lexical structure. Some of this complexity was inherited from C, and some is essential in the support of certain language features.

In this chapter, we'll examine a variety of syntax-related headaches. Some of these are common typos that nevertheless compile and execute in surprising ways. Others illustrate problems that arise due to a loose connection between the syntactic structure of a piece of code and its behavior at runtime. Still others will consider the problems occasioned by syntactic flexibility, when two programmers can examine the same piece of code and draw different conclusions about its meaning.

Gotcha #13: Array/Initializer Confusion

Let's allocate an array of 12 integers off ...

Get C++ Gotchas: Avoiding Common Problems in Coding and Design now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.