Delegating constructor and call to super

Robert M. Münch robert.muench at saphirion.com
Mon Jul 2 09:42:36 UTC 2018


class A {
	this(){...}
	this(int a) {...}
	this int a, int b){...}
}

class B {
	this(){... init some stuff for B ...}
	this(int a){super(a); this();}
}

Error: multiple constructor calls

I think it's because of "If a constructor's code contains a delegate 
constructor call, all possible execution paths through the constructor 
must make exactly one delegate constructor call"

But, how am I supposed to call the super(int) consturctor and put my 
common initialization code into a delegating constructor?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list