write(f)ln style exception factory
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 15 03:06:37 PDT 2014
On 2014-06-15 11:40, Dmitry Olshansky wrote:
> No, normal exceptions print just fine. e.g.
> writeln(new Exception("abc"));
> I'm wondering what's wrong the one I defined, the error message seems to
> indicate that it doesn't have toString. It's wrong as there is one
> derived from Exception.
>
> Workaround was to use
> alias toString = Base.toString;
Is this because "writeln" tries to use the one without parameters? If
you override one method, which as overloads, you need to override all
overloads or bring them into the same overload set with an alias, as
you've done above.
A base class and subclass have different overload sets [1].
[1] http://dlang.org/hijack.html search for "Derived Class Member
Function Hijacking".
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list