|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > The question is: If we are using a naming convention to denote public
> > and private data, how do you name 'InnerClass' and its private members?
> Got it.
> OuterClass
> OuterClass._private_static_of_OC
> OuterClass.public_static_of_OC
> OuterClass._InnerClass
> OuterClass._InnerClass.used_by_outerclass
> OuterClass._InnerClass._Used_only_by_innerclass
> Does that clarify?
> OuterClass could invoke
> x = _InnerClass.used_by_outerclass
> The trick is you shouldn't write "._" as part of a reference. :-)
But an outside code could do something along the lines of:
OuterClass::_InnerClass obj; // Assuming the compiler doesn't restrict this
obj.someFunction();
The first line clearly breaks the privacy contract, but with the second
line it's not so obvious anymore. It's calling a public member of _InnerClass,
but it's intended to be "public" only for OuterClass (because _InnerClass is
part of the private implementation of OuterClass), not for anything else.
--
- Warp
Post a reply to this message
|
 |