Adding overloaded methods
Jonathan M Davis
jmdavisProg at gmx.com
Tue Feb 21 18:39:06 PST 2012
On Wednesday, February 22, 2012 02:21:43 BLM wrote:
> I'm working on a project where I'm using overloaded virtual methods, and
> I've run into a challenge with overload sets.
>
> My code looks something like this:
>
> class Base {
> void get(ubyte b) {};
> }
>
> class Derived: Base {
> //alias Base.get get;
> void get(string s) {};
> }
>
> I've tried using an alias declaration to combine the two classes' overload
> sets in the derived class, but DMD complains that the alias conflicts with
> get(string). Is there some reasonably elegant way around this, or is it a
> limitation of the language?
Hmm. That's how you're _supposed_ to do it. Sounds like a bug.
http://dlang.org/function.html
It may be related to the fact that you don't have override on the derived
class's get though. You're really supposed to, but it hasn't been promoted to
an error yet (it's enabled with -w until it is). Try that and see if it fixes
it.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list