class constructor

gedaiu szabobogdan at yahoo.com
Sat Apr 13 00:36:50 PDT 2013


Hi,

Why in D this expression does not call the class constructor?

class A {

     int myVal;

     this(int val) {
        myVal = val;
     }

}


int main() {
    A myA = 8;
}


I would like to have a feature like this, because i want to 
create my own data type. I think it's possible, but i don't know 
why... std.variant, can be initialized like this.

Thanks!


More information about the Digitalmars-d-learn mailing list