constructor inheritance
Ary Borenszweig
ary at esperanto.org.ar
Wed Mar 5 04:51:43 PST 2008
Elwis wrote:
> Ary Borenszweig Wrote:
>
>> Elwis wrote:
>>> I might have described my problem unclearly.
>>>
>>> I has root class and it has some constructor. One of those just calls one of its methods. I'd like not to copy declaration of this constructor in all of its children.
>> Do you mean you don't want to have to do this?
>>
>> class Parent {
>>
>> this(int x, int y) {
>> // some code
>> }
>>
>> }
>>
>> class Child : Parent {
>>
>> // I wish the compiler would add the this(int x, int y) constructor
>> // automatically for me here
>>
>> }
>
> It doesn't work. Maybe it isn't supported by GDC?
Sorry for the misunderstanding. I didn't expect that to work, I was just
trying to see if that's what you wanted the compiler to do.
Anyway, I like Sean Kelly's proposal. But, if you have 15 constructors,
the problem may not be the language but a design flaw. Could you show in
which particular case you need to inherit constructors?
More information about the Digitalmars-d
mailing list