[Bug or feature] nested class inheritance
Bradley Smith
digitalmars-com at baysmith.com
Sun Apr 15 09:54:25 PDT 2007
Thomas Kuehne wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David Ferenczi schrieb am 2007-04-15:
>> Compiling the code below gives an error message:
>>
>> ----------------8<---------------------------------
>> int main(char[][] args)
>> {
>> class A
>> {
>> protected:
>> class AA {}
>> }
>>
>> class B : A
>> {
>> protected:
>> class BB : AA {}
>> }
>>
>> return 0;
>> }
>> ----------------8<---------------------------------
>>
>>
>> test.d(15): class test.main.B.BB super class AA is nested within A, not B
>>
>>
>> Is it the intended behaviour?
> Yes
>
>> Does it mean that nested classes wont get inherited, thus cannot be used in
>> the subclass?
>
> No. The classes are defined inside a function and thus:
> # (http://www.digitalmars.com/d/function.html)
> # Unlike module level declarations, declarations within function scope
> # are processed in order.
> #
>
> Thomas
I don't understand this answer. If the classes are moved to the module
level, the same error results. Why?
class A
{
protected:
class AA {}
}
class B : A
{
protected:
class BB : AA {}
}
int main(char[][] args)
{
return 0;
}
test.d(10): class test.B.BB super class AA is nested within A, not B
More information about the Digitalmars-d-learn
mailing list