Virtual Classes?
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 17 19:49:08 PDT 2016
On Thursday, 18 August 2016 at 00:49:49 UTC, Engine Machine wrote:
> https://en.wikipedia.org/wiki/Virtual_class
>
> Can D do stuff like this naturally?
Not naturally. The ancestor must be specified for the inner
"virtual class":
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
class Foo
{
class Internal
{
void stuff() {}
}
}
class Bar: Foo
{
class Internal: Foo.Internal
{
override void stuff() {}
}
}
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
However the ancestor inner class is well inherited (in the scope
of a derived class Internal resolves to the parent definition or
to the internal override when applicable).
Note that I find the wikipedia example very bad. "Parts" doesn't
define anything to override.
More information about the Digitalmars-d-learn
mailing list