implicit constructors
Trass3r
un at known.com
Thu Nov 24 13:48:13 PST 2011
> Seems like this is a CTFE-only issue?
No.
> import std.stdio;
> struct A
> {
> int store;
>
> this(int a)
> {
> store = a << 3;
> //...
> }
> }
// A a = 5; // Error: cannot implicitly convert expression (5) of type int
to A
void foo(A a)
{
}
> void main()
> {
> A a = 5; // fine
> writeln(a.store); // prints 40
foo(5); // Error: cannot implicitly convert expression (5) of type int to
A
> }
More information about the Digitalmars-d
mailing list