Adding overloaded methods

Jacob Carlborg doob at me.com
Tue Feb 21 23:19:09 PST 2012


On 2012-02-22 03:39, Jonathan M Davis wrote:
> 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

He is overloading, not overriding. You have to start notice the 
difference when reading these posts :)

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list