Accessing a function within an object's superclass from the outside
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 14 14:17:23 PST 2017
On Saturday, 14 January 2017 at 21:55:27 UTC, David Zhang wrote:
> Hello,
>
> Say I have a class, and it overrides a function from its
> superclass. However, the superclass has two overloaded versions
> of the same function. My intent is to override only one of the
> functions, but the second is rendered inaccessible from outside
> of the class. How can I make the overloaded function visible?
>
> ie:
>
> class ClassA {
> void fun(uint a) {}
> void fun(uint a, float b) {}
> }
>
> class ClassB: ClassA {
> void fun(uint a) {}
> }
>
> ca.fun(a); //ok
> ca.fun(a, b); //ok
> cb.fun(a); //ok
> cb.fun(a, b); //function fun not callable with uint and float
>
> I seem to remember something about using aliases to fix this,
> but I can't find anything about it either way.
class ClassB: ClassA {
alias fun = super.fun;
override void fun(uint a) {}
}
More information about the Digitalmars-d-learn
mailing list