Group: comp.lang.c++
From: "sk_usenet"
Date: Sunday, April 13, 2008 1:12 PM
Subject: Re: local class problem

"Stefan Ram" wrote in message
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>James Kanze writes:
>>>The declaration of a static variable inside a class
>>specifier
>>>is not a definition; it requires a definition elsewhere.
>>But if the type of a variable is »int«, the variable
>>also can be defined within the class specifier.
>
> Correction: This holds only for static /const/ fields.

Strictly speaking, statement made by James is correct.

Section 9.4.2/4
"If a static data member is of const integral or const enumeration type, its
declaration in the class definition can specify a constant-initializer which
shall be an integral constant expression. In that case, the member can
appear in integral constant expressions within its scope. **The member shall
still be
defined in a namespace scope if it is used in the program and the namespace
scope definition shall not contain an initializer.** "

Here *used* in the program means that the static const member is treated
like an l-value.
--
http://techytalk.googlepages.com


Safety Articles | Usenet Groups | Usenet News | Bluegrass