Abstract Classes

IM 3di at gm.com
Wed Dec 6 07:23:29 UTC 2017


Assume the following:

interface IFace {
   void foo();
   void bar();
}

abstract class A : IFace {
   override void foo() {}
}

class B : A {
   override void bar() {}
}

Now why this fails to compiler with the following message:


--->>>
function bar does not override any function, did you mean to 
override 'IFace.bar()'?
<<<---


Obviously, I meant that, since the abstract class A implements 
IFace, and B derives from A.

Do I need to declare IFace's unimplemented methods in A as 
abstract? If yes, why? Isn't that already obvious enough (any 
unimplemented virtual function is abstract)?


More information about the Digitalmars-d-learn mailing list