Home

In article <1190290249.900939.43190@22g2000hsm.googlegroups.com>,
James Kanze <james.kanze@gmail.com> wrote:
>On Sep 19, 9:15 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
>> t wrote:
>> > Lippman's C++ Primer says that if you initialize a const static data
>> > member in a class, you still need to define the member outside the
>> > class but without an initializer.
>
>> > I tried it using Visual C++ 2005 Express edition and get this error:
>
>> > 1>Account.obj : error LNK2005: "private: static int const
>> > Account::period" (?period@Account@@0HB) already defined in Account
>> > Main.obj
>
>> > Is this one of those things that vary by compiler? Is what Lippman
>> > said from Standard C++?
>
>> Yes. But it's only required for the variables that are used as
>> l-values (like when taking their address or binding a reference to
>> them).
>
>According to my copy of the C++ 1998 version of the standard,
>it's required, period. The latest draft makes an exception for
>variables which qualify for use in an integral constant
>expression, and for which all uses result in an immediate lvalue
>to rvalue conversion, but that's something which has been added.

This is one of those "funny ones". At least as I recall it,
the committee voted for (at least) the sentiment of the words in the
latest draft to have originally been included in C++98, however the
words got lost in some shuffle. So it was basically a typo
defect in the standard, although, clearly, the words themselves
are absent in the C++98 text, implying that it's fair to argue that
the behavior was not in C++98 if one take it literally, which one
usually should.
--
Greg Comeau / 4.3.9 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

previous
next

Launch file from Python
Re: A dumb question about a class
Re: [ANN] Python courses this Fall
Re: Pythonic way for missing dict keys
Re: reflection in c++
druk czasopism
SPA
fartuchy lekarskie
lubelskie
Zakopane Apartamenty