How to reserve memory for a slice in a struct

Diggory diggsey at googlemail.com
Tue May 7 09:15:45 PDT 2013


You could allocate space inside a class itself with something 
like this:
class Base {
     int[] slice;
}

template Derived(size_t N) {
     class Derived : Base {
         int[N] array;

         this() {
             slice = array;
         }
     }
}

Base b = new Derived!32();

A bit pointless though...


More information about the Digitalmars-d-learn mailing list