Abstract classes vs interfaces, casting from void*

Alex sascha.orlov at gmail.com
Sun Aug 11 20:15:34 UTC 2019


On Sunday, 11 August 2019 at 16:05:20 UTC, John Colvin wrote:
> I'm trying to narrow down exactly what patterns work with each 
> and how they overlap.
>
> What I was trying to get at with the abstract method thing is 
> that
>
> abstract class C
> {
>     void foo();
> }
>
> is an abstract class with a non-abstract method, whose 
> implementation is going to come from somewhere else (not a 
> common pattern in D).
>
> class C
> {
>     abstract void foo();
> }
>
> is an abstract class with an abstract method foo, which means 
> you have to override it in a inheriting class to get a 
> non-abstract class.

As I see this, everything you wrote is correct. :)

But you compared abstractness with interface usage, initially. 
So... I would say, interfaces are more like the abstract method 
case without any function body. But then, you will have to use 
"override" all across the inherited classes.


More information about the Digitalmars-d-learn mailing list