Null Statements

In C++, it's possible to have a null statement, a statement consisting entirely of a semicolon, as shown here:

Example 19-23. C++ Example of a Traditional Null Statement

while ( recordArray.Read( index++ ) != recordArray.EmptyRecord() )

The while in C++ requires that a statement follow, but it can be a null statement. The semicolon on a line by itself is a null statement. Here are guidelines for handling null statements in C++:

Call attention to null statements. Null statements are uncommon, so make them obvious. One way is to give the semicolon of a null statement a line of its own. Indent it, just as you would any other statement. This is the approach shown in the previous example. Alternatively, you can use a set of empty braces ...

Get Code Complete, Second Edition now with O’Reilly online learning.

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