[Bug 91] New: Inherited classes require base class to have a default constructor.
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Fri Apr 7 02:30:32 PDT 2006
d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=91
>
> Summary: Inherited classes require base class to have a default
> constructor.
> Product: D
> Version: 0.152
> Platform: PC
> OS/Version: Windows
> Status: NEW
> Severity: minor
> Priority: P2
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: eric96 at gmail.com
>
>
> Let me know if this is expected behavior or some rule I don't know about, but I
> think it's a bug. If you insert the default constructor "this(){}" in A, it
> compiles fine.
>
> // Looks like it requires the base class to have a default constructor.
> class A
> { this (int i) // constructor yage.a.this(int) does not match argument types
> ()
> {}
> }
> class B : A
> { this (int i)
> {}
> }
This is correct behaviour. Class B implicitly calls the default
constructor and if one is not found, an appropriate parent class
constructor call should be explicitly defined in B's constructor.
--
Jari-Matti
More information about the Digitalmars-d-bugs
mailing list