Is there any way to enforce the user to call the base-class ctor via
super(), so it's the first statement in his class ctor? e.g.:
class Base {
this(int) { }
}
class Derived : Base {
this(int x) {
super(x);
// user statements
}
}
The problem I'm having is that Base do
On Fri, 07 Oct 2011 18:02:33 -0400, Andrej Mitrovic
wrote:
Is there any way to enforce the user to call the base-class ctor via
super(), so it's the first statement in his class ctor? e.g.:
class Base {
this(int) { }
}
class Derived : Base {
this(int x) {
super(x);
/
Nope. Private ctors have to be called from within the same module,
whether implicit or not:
test.d:
class Foo
{
private this() { } // Error: constructor main.Bar.this no match
for implicit super() call in constructor
}
import test;
class Bar : Foo
{
this() { }
}
void main()
{
auto b
On Fri, 07 Oct 2011 23:02:33 +0100, Andrej Mitrovic
wrote:
So I'm looking for some techniques or tricks (or, dare I say, design
patterns :x) you guys might have if you've ever ran into this kind of
problem.
The best I can come up with is a runtime solution:
import std.stdio;
class Base {
On Tue, 11 Oct 2011 12:40:29 -0400, Andrej Mitrovic
wrote:
Nope. Private ctors have to be called from within the same module,
whether implicit or not:
test.d:
class Foo
{
private this() { } // Error: constructor main.Bar.this no match
for implicit super() call in constructor
}
import t