🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2130

Re: Proposal for a new access specifier

#2130
From: Mike McCormick
Date: Thu, 05 Oct 1995 18:43
32 lines
1849 bytes
I concur that "get methods" are tedious, and (unfortunately) ubiquitous.

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)
{
private:
	int readOnly;
public:
	const int* const pReadOnly;
};

In this class, readOnly is effectively a public-but-read-only attribute, 
thanks to the public pointer pReadOnly.  Outside Thing, readOnly can be read 
directly via *Thing.pReadOnly ... but pReadOnly and *pReadOnly are both 
protected from updates.


------------------------------------------------------------------
 Mike McCormick
 mtm4@rsvl.unisys.com
 m.mccormick2@genie.geis.com
------------------------------------------------------------------
 While you're out surfing the internet...
 I'm back on the beach blowing my little lifeguard whistle.
------------------------------------------------------------------

[ 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: <MTM4.1214.010BD7A3@rsvl.unisys.com>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: MTM4@rsvl.unisys.com (Mike McCormick)
Newsgroups: comp.std.c++
Subject: Re: Proposal for a new access specifier
Date: 5 Oct 1995 18:43:42 GMT
Organization: Unisys
Sender: news@rsvl.unisys.com (News Admin)
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <MTM4.1214.010BD7A3@rsvl.unisys.com>
References: <199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: mtm4
X-Newsreader: Trumpet for Windows [Version 1.0 Rev B]
Content-Length: 933
X-Lines: 28
Originator: clamage@taumet