Coderiving

Sean Kelly sean at f4.ca
Tue Nov 21 10:06:04 PST 2006


BCS wrote:
> Sean Kelly wrote:
>> Karen Lanrap wrote:
>>> Why one can derive from a nested class only in the corresponding 
>>> super class?
>>>
>>> The example gives the error:
>>>> super class Id is nested within Concept, not Concrete
>>>
>>> But Concrete is derived from Concept and should contain the 
>>> definition of the class Id!
>>
>> I think this is because inner classes can access data in the private 
>> scope of their surrounding class, and private class data should not be 
>> accessible by derived classes.
>>
>>
>> Sean
> 
> Based on that argument, this shouldn't work.
> 
> <code file="a.d">
> private int a;
> 
> class Foo
> {
>     void fig(){a++;}
> }
> </code>
> 
> <code file="b.d">
> class Bar : Foo
> {
>     void bar(){fig():}
> }
> </code>
> 
> 
> The derived nested class would have no more access than any other code. 
> Yes it could access protected stuff by way of of inherited members but 
> that is the way things are supposed to work.

I considered this before posting, and perhaps you're right.  Maybe this 
is just a technical issue, as I suspect the 'outer' pointer is handled 
differently than how parent class data is accessed.


Sean



More information about the Digitalmars-d-learn mailing list