[Bug or feature] nested class inheritance

Thomas Kuehne thomas-dloop at kuehne.cn
Sun Apr 15 08:56:26 PDT 2007


-----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


-----BEGIN PGP SIGNATURE-----

iD8DBQFGIleHLK5blCcjpWoRAsB0AKCN+BAUHrAq+ad72ZRge8zjOFXr7gCgrHEZ
fj21+kHJG+S+PePA05DG0dE=
=4Cpp
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list