From -2970148491880442894
X-Google-Thread: f78e5,f6130266038a8c4d
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!proxad.net!proxad.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: ben04_01@freenet.de (Ben Strasser)
Newsgroups: comp.std.c++
Subject: Re: Private Methodes declared outside of the class
Date: Wed, 18 Aug 2004 05:31:38 GMT
Lines: 52
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <2oco5cF9dtbhU1@uni-berlin.de>
References: <2oblfaF8nds3U1@uni-berlin.de> <_p6Uc.1281$g%5.16328@news2.e.nsc.no> <41211964$0$73936$14726298@news.sunsite.dk>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1092807106 6646 158.152.254.254 (18 Aug 2004 05:31:46 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 18 Aug 2004 05:31:46 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Orig-X-Trace: news.uni-berlin.de 3z4kOn1Iz8gogjlY1glMSAvZ3afYrazdornlAHNeWc2uNP6q/G
X-Spam-Status: No, hits=-4.2 required=5.2 tests=BAYES_00,FROM_ENDS_IN_NUMS 
	autolearn=no version=2.60-mulga_r1
X-Accept-Language: en-us, en
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i7I5Vc3e007900;
	Wed, 18 Aug 2004 15:31:38 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Spam-Level: 
X-Delivered-To: std-c++@ucar.edu
X-Spamscanner: mailbox8.ucsd.edu  (v1.4 May 20 2004 13:55:33, 1.0/5.0 2.63)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 76645 i7GLiGeZ091057 mailbox8.ucsd.edu)
Xref: g2news1.google.com comp.std.c++:1776

Thorsten Ottosen wrote:
 > ""Conrad Weyns"" <weyns@online.no> wrote in message 
news:_p6Uc.1281$g%5.16328@news2.e.nsc.no...
 > >
 > > "Ben Strasser" <ben04_01@freenet.de> wrote in message
 > > news:2oblfaF8nds3U1@uni-berlin.de...
 > > > Hello,
 > > >
 > > > I was wondering why you can not declare private methods outside 
of the
 > > > class declaration?
 >
 > because it's not needed.

And why is it not needed? Because there's a workaround which allows you 
to do a simple thing the hard way?

PImpl adds extra indirections, which are slower than when using a C 
interface (compare this->imp->data to handle->data) but worse is the 
extra indirection in the source code which makes you have to actually 
think that imp->imp_foo() is actually calling a member of the same class.

To be able to call a public (or inherited protected get function) you 
also need to make all functions in the Implementation static and pass 
them manually the this pointer (so that you can access the protected 
members of the base class). Now we have passed_this->imp->data and 
imp->imp_foo(this) standing in the actual source code. Not quiet my 
definition of readable code.

Ok we could leave the private methods non static but then 2 pointers 
will be passed to each call => again a slowdown compared to C (wasn't 
C++ supposed to be a combination of C's speed with OO?).

 > > As Bob said, the Pimpl idiom will help you out.
 > > But you can often get away with mere static functions.
 > > All you need is to declare friendship:
 >
 >Actually friendship is not even needed. just add functions with 
 >appropriate arguments
 >in the implementation file.

So how do you do inheritance?

The pImpl is not bad as a workaround but it is and stays a workaround to 
replace a missing feature.

---
[ 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                       ]



