Abstract classes vs interfaces, casting from void*
Alex
sascha.orlov at gmail.com
Sun Aug 11 21:23:10 UTC 2019
On Sunday, 11 August 2019 at 20:32:14 UTC, John Colvin wrote:
>> 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.
>
> Ok. So that means the difference is pretty subtle, give or take
> a few extra keywords.
>
> Which leaves multiple inheritance as the only significant
> difference?
>
> From my perspective it looks like there are two massively
> overlapping features with some quite arbitrary feeling
> restrictions and differences. E.g. why can I not inherit from
> multiple 100% abstract empty classes? Wouldn't that be the same
> as inheriting from multiple interfaces?
The overlap is there, but it is not so massive, I would say. If
you inherit from abstract classes, then you do not plan to keep
them empty.
So, the overlap you are speaking about is exactly as large as the
amount of "100% abstract empty classes". And for these, the
approach to keep the interface as a separate interface seems more
convenient, as Adam said.
In the end, by forcing an explicit override, some semantic is
also implied.
More information about the Digitalmars-d-learn
mailing list