Article View: comp.std.c++
Article #2808Re: Can I declare private constants?
From: Ulf Schuenemann
Date: Thu, 30 Nov 1995 19:25
Date: Thu, 30 Nov 1995 19:25
48 lines
2296 bytes
2296 bytes
In article <49fne0$nbl@engnews1.eng.sun.com>, clamage@Eng.Sun.COM (Steve Clamage) writes:
[..]
|> The appropriate comparison would be with
|> extern const int X__fifty = 50;
|> which would appear in exactly one place, and
^^^^^^^^^^^^^^^^^ (*)
|> extern const int X__fifty;
|> every place else.
Sorry, I've messed it up. I meant "extern const"
instead of "const" and thought
extern const int X__fifty = 50;
could stand in multiple translation units and would be enough.
DWP 7.1.5.1 [dcl.type.cv], 2:
> Unless explicitly declared extern, a const object
> does not have external linkage
> and shall be initialized (8.5, 12.1);
^--(#)
Does this mean that it _may_ _not_ be initialized
if explicitly declared extern (like (*) sugggests)?
The DWP continues:
> ... [can call default-ctor] otherwise if the const object is not
> initialized with an explicit initializer the program is ill-formed.
So does the "Unless explicitly declared extern" extend beyond
the semicolon (#) up to the definition of ill-formed ?
Then the wording is missleading, at least for my english skills.
Otherwise "extern const int i;" would be ill-formed.
Ulf Schuenemann
--------------------------------------------------------------------
,_. Ulf Schuenemann
#, \ Fakultaet fuer Informatik, Technische Universitaet Muenchen, Germany.
| > email: schuenem@informatik.tu-muenchen.de
v=-< WWW: http://hphalle2.informatik.tu-muenchen.de/~schuenem/
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<49kge5$imb@sunsystem5.informatik.tu-muenchen.de>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<49fe01$62g@sunsystem5.informatik.tu-muenchen.de> <49fne0$nbl@engnews1.eng.sun.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann) Newsgroups: comp.std.c++ Subject: Re: Can I declare private constants? Date: 30 Nov 1995 19:25:40 GMT Organization: Technische Universitaet Muenchen, Germany Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <49kge5$imb@sunsystem5.informatik.tu-muenchen.de> References: <49fe01$62g@sunsystem5.informatik.tu-muenchen.de> <49fne0$nbl@engnews1.eng.sun.com> NNTP-Posting-Host: physics2.berkeley.edu