why does a constructor with default arguments fail to match, when default construction is disabled?

DanielG simpletangent at gmail.com
Sat Aug 22 05:50:00 UTC 2026


here's another version of the code with reduced comments for 
easier reading on the website:

```
import std.stdio;

class MyClass {
	@disable this();

	this(string y = "hi") {
		writeln("hello from MyClass constructor");
	}
}

void main()
{
	// always works
	auto x = new MyClass("hi");

	// error, depending on @disable this()
	// why won't it match the ctor with default args?
	auto y = new MyClass();
}
```



More information about the Digitalmars-d-learn mailing list