variadic func to call another variadic func
Daniel919
Daniel919 at web.de
Thu Aug 24 15:12:33 PDT 2006
Hi, I tried to create a simple solution for constructor inheritance
(http://www.digitalmars.com/pnews/
read.php?server=news.digitalmars.com&group=digitalmars.D.announce&artnum=4426)
The example code illustrates the problem, called in the topic.
--------------------------------------------------------------
import std.string;
import std.stdio;
class Base {
this() {
m_val = -1;
}
this(int val) {
m_val = val;
}
int m_val;
}
class Derived : Base {
this(...) {
super(_arguments); // <= the problem
// ... do some special Derived constructor stuff
}
}
void main() {
Derived obj1 = new Derived();
writefln("obj1.m_val: " ~ format(obj1.m_val));
Derived obj2 = new Derived(12345);
writefln("obj2.m_val: " ~ format(obj2.m_val));
}
--------------------------------------------------------------
The constructor of Derived has to call the constructor of Base with
the same parameters itself got called.
What would be the best way to do this ?
[Sorry for not posting this in digitalmars.D, but that forum isn't
working for me]
Thanks for your replies in advance,
Daniel
More information about the Digitalmars-d-announce
mailing list