Error: 'this' is only defined in non-static member functions

Mike Parker aldacron at gmail.com
Thu Nov 23 00:49:33 UTC 2017


On Wednesday, 22 November 2017 at 22:45:53 UTC, A Guy With a 
Question wrote:

> Out of curiosity, what does static mean in that context? When I 
> think of a static class I think of them in the context of Java 
> or C# where they can't be instantiated and where they are more 
> like namespaces that you can't directly import the contents of.

Actually, they work exactly like Java's static nested classes in 
this context.


class OuterClass {
     ...
     static class StaticNestedClass {
         ...
     }
}

OuterClass.StaticNestedClass nestedObject =
      new OuterClass.StaticNestedClass();

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html


More information about the Digitalmars-d-learn mailing list