Article View: comp.std.c++
Article #3825Suggestion to the C++ standard
From: Marueli Sunny
Date: Wed, 27 Mar 1996 10:16
Date: Wed, 27 Mar 1996 10:16
41 lines
1758 bytes
1758 bytes
Hello.
C++ is an OO language, and of course supports encapsulation.
Problem is - there is no standard way to add access methods.
For example:
class foo
{
public:
SetMember( Type aMember );
Type Member( );
private:
Type Member;
};
Now, this code is reasonable, but it could be better:
[ I really don't know where I'm stealing this syntax. Sorry, anyway ]
class foo
{
private:
Type Member : read GetMember, write SetMember;
};
and then you can do something like:
foo x;
x.Member = 5; // Calls SetMember()
cout << x.Member; // Calls GetMember()
I think this kind of code is much more elegant, and forces the use of
access methods, which isn't bad by itself.
------------
Sunny
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<4jatnm$s9b@post.tau.ac.il>Path:
arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back From: sunny@libra.math.tau.ac.il (Marueli Sunny) Newsgroups: comp.std.c++ Subject: Suggestion to the C++ standard Date: 27 Mar 96 10:16:45 GMT Organization: School of Math & CS - Tel Aviv University , Tel Aviv , ISRAEL. Approved: fjh@cs.mu.oz.au Message-ID: <4jatnm$s9b@post.tau.ac.il> NNTP-Posting-Host: munta.cs.mu.oz.au X-Original-Date: 27 Mar 1996 08:20:06 GMT X-Newsreader: TIN [version 1.2 PL2] X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMVkVmeEDnX0m9pzZAQEaUQF/TLrMWHDsUcihK8Qgk+oHmoXNbV0SpBcu SwLiyrWyOSFrMrEpsbO3olNfB5rQaTNE =e0ru Originator: fjh@munta.cs.mu.OZ.AU