Static method of inner class needs this

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 9 01:24:21 PST 2015


On Monday, 9 February 2015 at 07:32:33 UTC, rumbu wrote:
> class Outer
> {
>     class Inner
>     {
>         static Inner createInner()
>         {
>             return new Inner(); //need 'this' to access member 
> this
>         }
>     }
> }
>
> Is this a bug?
>
> If Inner is not nested, it works as expected:
>
> class Inner
> {
>     static Inner createInner()
>     {
>         return new Inner()
>     }
> }
>
> D version: 2.066.1

In the first case, is there an "Inner" that is visible outside of 
"Outer"?
If so, the compiler wont know which one your talking about, so 
need to specify with this.


More information about the Digitalmars-d-learn mailing list