alias this ...

BLS windevguy at hotmail.de
Mon Sep 6 13:36:49 PDT 2010


// ..snip
     point3D p; // Da
     p.x = 10;
     p.y = 20;
     p.z = 100;

     point3D = = new point3D(10,20,30) // Njet
     //etc
}

struct point {
     int x;
     int y;
}

struct point3D {

     point p;
     alias p this;
     int z;

     // NOPE :(
     /*static point3D opcall(int _x, int _y, int _z) {
         // ..snip
     }*/

     // NOPE :(
     /*
     this(int _x, int _y, int _z) {
         // .. snip
     }
     */
}
would be nice to use alias this as struct inheritance substitute, 
especially in conjunction with Implements!()

But maybe I don't get the "alias this" thingy. So what's my mistake > TIA


More information about the Digitalmars-d-learn mailing list