Override in user type in D

I remember reading somewhere that you can override the .init property of custom types in D. I would like to do this for the structure I created, but I find no way to do this, especially since default constructors are not allowed. Is this possible, and if so, how can I do this?

+8
data-structures d
source share
1 answer

you can specify field initialization values ​​(only with compilation hours)

struct foo{ int a=0; real b = 5.0; } 

foo.init will then be equal to foo(0,5.0)

+10
source share

All Articles