super constructors question

Serg Kovrov kovrov at no.spam
Sun Aug 13 06:07:07 PDT 2006


Hello everybody,

Could someone explain why D do not lookup for appropriate super
constructor? It is in specs:
> If there is no constructor for a class, but there is a 
> constructor  for the base class, a default constructor 
> of the form:
> this() { }
But i do not understand intension. Is it so hard for compiler to find
suitable constructor in base class(es)?

simple example:
> class Foo
> {
>   this(char[] name) { }
> }
> 
> class FooBar : Foo
> {
>   /* no ctors defined */
> }

Calling `auto o = new FooBar("test")` result to "constructor FooBar.this
no match for implicit super() call in constructor" message.

Thanks.
-- 
serg.



More information about the Digitalmars-d-learn mailing list