Programming in D page 295 - disable default constructor

monkyyy crazymonkyyy at gmail.com
Tue Feb 10 21:10:06 UTC 2026


On Tuesday, 10 February 2026 at 13:23:43 UTC, Brother Bill wrote:
> On Tuesday, 10 February 2026 at 12:50:16 UTC, monkyyy wrote:
>> ```d
>> import std;
>> struct foo{
>> 	int i,j;
>> 	this(int a, int b){
>> 		j=a;
>> 		i=b;
>> 	}
>> }
>> unittest{
>> 	auto bar=foo(1,2);
>> 	bar=foo(3);
>> }
>> ```

> If you remove this(int a, int b), it will also fail to compile.

no


More information about the Digitalmars-d-learn mailing list