Lack of `outer` keyword makes inner class dup implossible
Derek Parnell
derek at psych.ward
Fri Jul 14 21:10:41 PDT 2006
On Sat, 15 Jul 2006 13:37:11 +1000, Jarrett Billingsley
<kb3ctd2 at yahoo.com> wrote:
> "Derek Parnell" <derek at psych.ward> wrote in message
> news:op.tcpklel16b8z09 at ginger.vic.bigpond.net.au...
>
>> Excuse my ignorance, but what does an inner class provide that other
>> alternatives can't?
>
> Well, what does a nested function provide that a separate, external
> function
> doesn't?
>
> - Encapsulation
> - Access to outer variables
> - Is a Cool Thing (TM) ;)
>
> Pretty much the same thing applies to inner classes, although I'll grant
> you, I don't use inner classes as much as nested functions.
Ok, assuming that 'nested' and 'inner' are synonymous in this discussion,
it appears that their main purpose is to provide scope limitation. That
is, the functionality provided by inner classes/functions is restricted
to, and there by only relevant to, the containing class/function.
I use inner functions this way because I can see their utility, but can
someone supply a good inner class example? As far as I can see, an
instance of an inner class only makes sense in the context of its parent
class and is thus reliant on the 'outer' class for relevancy. I'm having
trouble visualizing where this might be a Cool Thing(TM).
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list