Errata

C++ The Core Language

Errata for C++ The Core Language

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 37
"Other Class Members" box

Not an "error" but an important omission, and it may just be a Microsoft variation,
but here goes:

In Microsoft Visual C, a static variable declared in a class must also be declared at
file scope, outside the class declaration. Also, if it is going to be initialized to
some value, it can only be initialized at file scope.

So the declaration would be:

class Foo {
public:
...
static int staticDataMem;
...
};

int Foo::staticDataMem; // File scope declaration
/* or
int Foo::staticDataMem = 3;
*/

I spent a little time pulling my hair out until I found this in Microsoft
documentation.

Note from the Author or Editor:
I don't have access to a Microsoft compiler to test this.

Anonymous