Replacement for C++ Style Implicit casts?

Mike Chaten mchaten at
Mon Oct 18 12:47:40 PDT 2010

In C++ it is possible to declare a class as follows
class Foo {
Foo(int x) { }
You can then use that constructor to implicitly convert int to Foo. E.g
Foo x = 0; //equivalent to Foo(0)

Is there a way in D to do an implicit or explicit conversion from an
integral type to a class?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d-learn mailing list