Coderiving

BCS BCS at pathilink.com
Tue Nov 21 09:24:01 PST 2006


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.



More information about the Digitalmars-d-learn mailing list