From -8055792737527360454
X-Google-Thread: f78e5,f6130266038a8c4d
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!feed.news.tiscali.de!easynet-monga!easynet.net!news.clara.net!wagner.news.clara.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: loic.actarus.joly@wanadoo.fr (=?ISO-8859-1?Q?Lo=EFc_Joly?=)
Newsgroups: comp.std.c++
Subject: Re: Private Methodes declared outside of the class
Date: Thu, 19 Aug 2004 15:49:23 GMT
Organization: Wanadoo, l'internet avec France Telecom
Lines: 56
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <cg1vf7$nfe$1@news-reader5.wanadoo.fr>
References: <2oblfaF8nds3U1@uni-berlin.de> <cfvuts$sen$1@news1nwk.SFbay.Sun.COM>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-Trace: news.demon.co.uk 1092930568 43 158.152.254.254 (19 Aug 2004 15:49:28 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Thu, 19 Aug 2004 15:49:28 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.cs.mu.OZ.AU id i7JFnNYZ004430
X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham 
	version=2.64-mulga_r1
X-Accept-Language: en-us, en
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i7JFnNuo004421;
	Fri, 20 Aug 2004 01:49:23 +1000 (EST)
X-NNTP-Posting-Date: 19 Aug 2004 10:29:59 GMT
X-Spam-Level: 
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:1855

Steve Clamage wrote:

> Ben Strasser wrote:
>=20
>>
>> I was wondering why you can not declare private methods outside of the=
=20
>> class declaration?
>=20
>=20
> If you could declare member functions outside the class definition,=20
> anyone could hijack the class (for good or bad purposes), or break the=20
> class invariants without anyone knowing.

Not if you can write only private non-virtual functions outside of the=20
class : Sure you could add functions to the class, but nobody except the=20
implementation of the class would be able to call them.


> The existing rule means that the entire class interface is visible in=20
> the class declaration, and you have a complete list of everything=20
> (members and friends) that could be affected by an internal=20
> implementation change.
>=20
> This rule works against information hiding, but that was not a design=20
> goal of C++ classes.

I'm not sure what you do mean by hiding here. If you mean hiding to=20
human, I do not care. If you mean hiding from all the code using a class=20
that something internal to this class has been changed, I think it would=20
be worthwile.
It could even lead to header files being more "write protected" than=20
implementation files.


There are currently alternatives :
- PIMPL : Has an overhead, requires some changes in the class definition=20
to switch from a non-pimpl to a pimpl class. It can still be usefull for=20
private data, and for hiding to the human.
- Use only free functions for implementation, pass them all they need in=20
argument : That make function with long argument lists, which are a pain=20
to write and a pain to use.

Although I understand the current rules for data, or for virtual,=20
protected of public functions, I believe it would be really easy to=20
relax those rules for private-non virtual functions.

--=20
Lo=EFc

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



