How to implement private constructor

Vinod K Chandran kcvinu82 at gmail.com
Mon Apr 25 00:18:03 UTC 2022


Hi all,
Please take a look at this code. Is this the right way to use 
private constructors ?
```d
class Foo {
     int p1 ;
     string p2 ;
     bool p3 ;

     private this(int a, string b, bool c) {
         this.p1 = a
         this.p2 = b
         this.p3 = c
     }

     this(int a) {
         this(a, "some string", true);
     }

     this(int a, string b) {
         this(a, b, true);
     }
}
```



More information about the Digitalmars-d-learn mailing list