My bad; I wasn't thinking straight. Let's do it as Ingo has proposed:
class BRoster {
public:
[...]
/*----- Private or reserved ------------------------------*/
class Private;
private:
friend class Private;
[...]
};
e
>"Erik Jaesler" <erik@xxxxxxxxxxxxxx> wrote:
>>
>> >> A last note: rather than declare them as members of the classes
>> > > they
>>
>> >> provide access to, I'd like to put them in the BPrivate namespace
>> > > --
>> >> like BLooperList. The idea being that if you declare them as
>> > > class
>> >> members, then they have to be in the public interface, and end-
>> > > users
>> >> may
>> >> be tempted to use them.
>> >
>> >That should turn out to be difficult, since the class is opaque in
>> > any
>> >case. :-P
>>
>> How so=3F If it's declared within the main class, the interface will
>> be
>> right there. Unless we give the private accessor class methods some
>> very obnoxious names, it should be pretty obvious what they do.
>
>Nah, only the class name would appear in the header, not the class
>interface. Cf. Roster.h:
>
>class BRoster {
>public:
>[...]
>/*----- Private or reserved ------------------------------*/
> class Private;
>
>private:
> friend class Private;
>[...]
>}
>
>> >An API user with a sufficent amount of criminal energy can abuse the
>> >private class anyway, regardless of whether it lives in the BPrivate
>> >namespace or in the class itself.
>>
>> True enough. A user willing to go to that length will also make his/
>> her
>> own copy of the header, declare themselves a friend and have all the
>> fun
>> they want. The point is more to keep this stuff out of the way --
>> why
>> clutter up the public API headers any more than absolutely
necessary=3F
>
>Exactly my opinion. :-)
>
>> >> Better to hide them away in BPrivate.
>> >
>> >What I find a bit ugly with that solution is that you have to
>> > declare
>> >the class in the namespace in the public header (even before the
>> >definition of the main class).
>>
>> Yeah, it's a tiny bit ugly, but nothing truly onerous. I suspect
>> most
>> people will hardly notice the four lines of code (total) involved.
>
>Even less ugly are just two additional lines in the `private or
>reservered' region. :-P
>
>CU, Ingo
>
Necessity is the plea for every infringement of human freedom. It is the
argument of tyrants; it is the creed of slaves.
-William Pitt, British prime-minister (1759-1806)