Inner classes question

Ivan Senji ivan.senji_REMOVE_ at _THIS__gmail.com
Sun Sep 10 03:34:23 PDT 2006


I know this (or something like this) has been discussed before but I 
have to ask anyway, let's say I have

class O
{
   class I1
   {
   }
   class I2
   {
     I1 a = new I1; //line 8
   }
}

This is currently impossible because of:

(8): outer class O 'this' needed to 'new' nested class I1

Once again the outer keyword is missing.
The compiler is being very helpful by saying that I need outer's class 
this pointer, but it isn't telling me how to get it. (Is there any way?)
For I2 to be created outer's class this must have existed and it must be 
stored in I2's instance so I don't see the need in any special syntax.
new I1 should be enough.

I know about the workaround solutions of passing O.this to I1 and I2 
constructors but aren't inner classes here to avoid that very coding 
pattern?
Something (adding outer?) must be done about this.



More information about the Digitalmars-d-learn mailing list