Implicit conversion with ctor like C++
Pierre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 8 12:23:45 PDT 2015
Hi everybody,
I would like to use implicit conversion like this:
//Sample class
class MyClass
{
this(string MyValue){...}
}
//Called function
void MyFunction(Foo MyFoo){}
void main()
{
MyFunction("Hello World!"); //Failed : MyFunction not
callable...
}
I saw in forum this is OK because D doesn't do implicit
conversion with ctor like C++
But how can I do ? May I use alias ?
Thank you for your attention.
More information about the Digitalmars-d-learn
mailing list