On Wed, Mar 12, 2003 at 11:27:37PM -0500, Stefanus Du Toit wrote:
> On Thu, Mar 13, 2003 at 01:02:35AM +0200, Tuomo Valkonen wrote:
> > Is it somehow possible, without doing it individually for all those
> > functions, to define non-class functions in a file "friends" for a
> > class so that protections don't apply?
>
> I suspect what you want is something like the "pimpl" idiom as
> outlined in Sutter's "Exceptional C++". It's not the nicest name but
> it works out quite nice (pimpl stands for "private implementation").
Thanks Stefanus. This is much cleaner than the friend classes that I
suggested. Downsides are you end up writing lots of wrapper functions in Foo
to call the actual methods in FooImpl, and it adds another
> For more information, see Herb Sutter's "Exceptional C++"
> (Addison-Wesley Longman, 2000). It's good some good tricks like the
> above and is very readable.
This is an excellent book. Much of the content is online at
http://www.gotw.ca/gotw/index.htm
so you can try before you buy. As it says in the introduction, it's a book
for people who _think_ they know all of C++.
Caveat: reading this book caused me to quit programming in C++. It shows you
just how hard it is actually write proper C++ unless you stick to a very
limited subset of features.
Regards,
Tom