Article View: comp.std.c++
Article #2758Re: Can I declare private constants?
From: Ulf Schuenemann
Date: Tue, 28 Nov 1995 17:40
Date: Tue, 28 Nov 1995 17:40
50 lines
1987 bytes
1987 bytes
In article <48su7l$4hj@engnews1.eng.sun.com>, clamage@Eng.sun.com (Steve Clamage) writes:
[..]
|> >class X
|> >{
|> >static const int fifty;
|> >...
|> >};
|> >int X::fifty = 50;
^^^^^^^^^^^^^^^^^ (*)
|>
|> But why not use the method that preserves the original intent of having
|> fifty be a manifest constant?
|>
|> class X {
|> static const int fifty = 50;
|> };
|> and then in one place
|> int X::fifty;
Coz I've to designate once and forever one file to contain this
definition and to link it whenever I use class X.
class X
{
};
const int X__fifty = 50;
It this works, why cant (*) work the same way ? The only
difference is, that X::fifty is a member and X__fifty isn't.
Besides membership X__fifty gives us what we want:
(a) use it as constant expression
(b) no need for a special implementation-file.
Why do we have to pay for membership by giving up property (b) ?
I cant see a rationale behinde it.
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:
<49fe01$62g@sunsystem5.informatik.tu-muenchen.de>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<48r6un$ms2@rcogate.rco.qc.ca> <48su7l$4hj@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: 28 Nov 1995 17:40:52 GMT Organization: Technische Universitaet Muenchen, Germany Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <49fe01$62g@sunsystem5.informatik.tu-muenchen.de> References: <48r6un$ms2@rcogate.rco.qc.ca> <48su7l$4hj@engnews1.eng.sun.com> NNTP-Posting-Host: physics2.berkeley.edu