...

/

alias: Revealing Hidden Names of Superclasses

alias: Revealing Hidden Names of Superclasses

Get to learn how an alias can be used for revealing hidden names of superclasses.

We'll cover the following...

Revealing hidden names of superclasses

When the same function name appears both in the superclass and in the subclass, the matching names that are in the superclass are hidden. Even a single name in the subclass is sufficient to hide all of the names of the superclass that match that name:

Press + to interact
class Super {
void foo(int x) {
// ...
}
}
class Sub : Super {
void foo() {
// ...
}
}
void main() {
auto object = new Sub;
object.foo(42); // ← compilation ERROR
object.foo(67, 49); // ← compilation ERROR
}

Since the argument is 42, an int value, one might expect that the Super.foo function that takes an int would be called for that use. ...