Article View: comp.std.c++
Article #2163Re: Proposal for a new access specifier
From: Ulf Schuenemann
Date: Tue, 10 Oct 1995 18:49
Date: Tue, 10 Oct 1995 18:49
49 lines
2552 bytes
2552 bytes
In article <MTM4.1214.010BD7A3@rsvl.unisys.com>, MTM4@rsvl.unisys.com (Mike McCormick) writes:
|> However, there is an alternative to changing the standard which I have not
|> seen mentioned here yet. That is, public const pointers:
|>
|> class Thing :
|> pReadOnly(&readOnly)
^^^^^^^^^^^^^^^^^^^^ - you mixed class and ctor.
|> {
|> private:
|> int readOnly;
|> public:
|> const int* const pReadOnly;
|> };
Unfortunatly, now every instance gets an additional pointer.
If one could declare, that every ctor of Thing initializes
pReadOnly the same way so that for every instance pReadOnly
points to the same attribute, then pReadOnly could be optimized
away (like global const).
This is an example where it would be usefull to be able to initialize
not only static but also nonstatic datamembers inside the class defn.
class Thing {
private:
int readOnly;
public:
const int* const pReadOnly = &readOnly; // ILLEGAL
};
[ Regarding how hard it was to introduce this for static members
it seems unlikely to be allowed for nonstatic members. ]
Ulf Schuenemann
--------------------------------------------------------------------
,_. Ulf Schünemann
#, \ Fakultät für Informatik, Technische Universität München, 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:
<45e5v6$3ac@sunsystem5.informatik.tu-muenchen.de>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net> <MTM4.1214.010BD7A3@rsvl.unisys.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann) Newsgroups: comp.std.c++ Subject: Re: Proposal for a new access specifier Date: 10 Oct 1995 18:49:35 GMT Organization: Technische Universitaet Muenchen, Germany Sender: USENET Newssystem <news@informatik.tu-muenchen.de> Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <45e5v6$3ac@sunsystem5.informatik.tu-muenchen.de> References: <199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net> <MTM4.1214.010BD7A3@rsvl.unisys.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: TEXT/PLAIN; charset="UNKNOWN-8BIT" Content-Transfer-Encoding: QUOTED-PRINTABLE X-Nntp-Posting-Host: hpbroy3.informatik.tu-muenchen.de Originator: schuenem@hpbroy3.informatik.tu-muenchen.de X-Lines: 45 Content-Length: 1395 Originator: clamage@taumet