Can't create nested classes

Heinz billgates at microsoft.com
Mon Jan 22 20:00:20 PST 2007


Jarrett Billingsley Wrote:

> 
> "Heinz" <billgates at microsoft.com> wrote in message 
> news:ep408i$2389$1 at digitaldaemon.com...
> 
> >        private Table mytable = new Table();
> 
> You're not allowed to have non-constant expressions in class member 
> initializers.  Move this 'new' into a constructor for myclass. 
> 
> 

Check this out, if i write this code it works:

class myclass
{
       private Table mytable;

       this()
       {
               mytable = new Table();
        }
}

but if i write this code i get an access violation:


class myclass
{
       private Table mytable, mytable2;

       this()
       {
               mytable = new Table();
               mytable2 = new Table();
        }
}

And of course i need the second block of code.


More information about the Digitalmars-d-learn mailing list