Article View: comp.std.c++
Article #2785Re: Can I declare private constants?
From: Fergus Henderson
Date: Thu, 30 Nov 1995 00:42
Date: Thu, 30 Nov 1995 00:42
38 lines
1789 bytes
1789 bytes
schuenem@informatik.tu-muenchen.de (Ulf Schuenemann) writes:
>clamage@Eng.sun.com (Steve Clamage) writes:
>[..]
>|> >class X
>|> >{
>|> >static const int fifty;
>|> >...
>|> >};
>|> >int X::fifty = 50;
> ^^^^^^^^^^^^^^^^^ (*)
[...]
>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.
No, there is another, very signficant (from a compiler implementor's
perspective) difference -- X__fifty has internal linkage,
whereas X::fifty has external linkage. If you take the address
of X__fifty in two different translation units, you will get
different results. If you take the address of X::fifty in two different
translation units, you will get the same result.
--
Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3
I will have little or no net access from Nov 30 until Dec 25,
so please email me a copy of any follow-ups.
---
[ 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:
<9533411.19931@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<48r6un$ms2@rcogate.rco.qc.ca> <48su7l$4hj@engnews1.eng.sun.com> <49fe01$62g@sunsystem5.informatik.tu-muenchen.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson) Newsgroups: comp.std.c++ Subject: Re: Can I declare private constants? Date: 30 Nov 1995 00:42:29 GMT Organization: Computer Science, University of Melbourne, Australia Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <9533411.19931@mulga.cs.mu.OZ.AU> References: <48r6un$ms2@rcogate.rco.qc.ca> <48su7l$4hj@engnews1.eng.sun.com> <49fe01$62g@sunsystem5.informatik.tu-muenchen.de> NNTP-Posting-Host: physics2.berkeley.edu