Explicit default constructor for structs
Jacob Carlborg
doob at me.com
Wed Apr 9 12:57:24 PDT 2014
On 2014-04-09 19:10, Brian Schott wrote:
> Really? What does this program print using a current version of DMD?
>
> import std.stdio;
>
> struct SomeStruct
> {
> this(int i = 10)
> {
> this.i = i;
> }
> int i;
> }
>
> void main(string[] args)
> {
> auto s = SomeStruct();
> writeln("s.i = ", s.i);
> }
>
> I don't think it would be ambiguous at all :-)
Yeah, because currently DMD doesn't have the proposed feature. If it's
added I can imagine it's similar to writing this:
void foo ();
void foo (int i = 0);
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list