reimplementing an interface in a derived class

Heromyth bitworld at
Thu Jan 10 02:14:26 UTC 2019

On Thursday, 3 January 2019 at 23:23:12 UTC, Neia Neutuladh wrote:
> On Thu, 03 Jan 2019 22:30:48 +0000, kdevel wrote:
>> class A : D {
>>      int foo() { return 1; }
>> }
>> class B : A, D {
>> [...]
>> What is the meaning of the ", D"? It does not seem to make a 
>> difference if it is omitted.
> B must provide its own implementation of D. It can't simply use 
> A's implementation.

As for class B, it has already included foo(), even if it doesn't 
override this method. So, is it necessary to override it again? 
It not always needed to override foo(). Sometimes, we just want 
to keep it as the one in class A and override it as necessary. 
Honestly hope that the compiler can do this.

More information about the Digitalmars-d-learn mailing list