D - bug: ctors with inheritance
- Carlos Santander B. (17/17) Oct 24 2003 The following doesn't compile:
- Vathix (6/18) Oct 25 2003 You have to satisfy one of the super class' constructors; the compiler o...
The following doesn't compile: class A : Exception {} void main() { throw new A; } DMD outputs: "constructor this (char[]msg) does not match argument types ()" If I write throw new A("something"); instead, it outputs exactly the same. Two more things: someone (sorry, can't remember) once said that error messages regarding constructor didn't specify which line. That's annoying. Also, I can't remember which was the syntax for not writing "this(char[]msg){super(msg);}" for each class derived from Exception. Can somebody please refresh my mind? ------------------------- Carlos Santander --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.530 / Virus Database: 325 - Release Date: 2003-10-22
Oct 24 2003
The following doesn't compile: class A : Exception {} void main() { throw new A; } DMD outputs: "constructor this (char[]msg) does not match argument types()"If I write throw new A("something"); instead, it outputs exactly the same.You have to satisfy one of the super class' constructors; the compiler only knows how to insert a call to super() if it takes no parameters, you must explicitly call one otherwise.Two more things: someone (sorry, can't remember) once said that error messages regarding constructor didn't specify which line. That's annoying. Also, I can't remember which was the syntax for not writing "this(char[]msg){super(msg);}" for each class derived from Exception. Can somebody please refresh my mind?Constructors aren't inherited like other member functions (which I think they should...) so you have to write that.
Oct 25 2003