D vs C++ classes?
IGotD-
nise at nise.com
Tue Jun 22 09:04:05 UTC 2021
On Tuesday, 22 June 2021 at 02:13:33 UTC, zjh wrote:
>
> multiple inheritance is very good.I dont know why they are
> objective.
> 10+ years ago,they refuse to listen others' suggestion.
> I dont know if they still refuse now.
It's because the diamond problem. The diamond problem is purely
an academic problem and it very seldom happens in the real world
and if it does you probably did something wrong in your design.
Happen to me once in 30 years because I messed up. Multiple
inheritance is often flat, which means that one class inherits
from several others at the same level. Instead of disallow
multiple inheritance you can disallow the diamond pattern.
D went another way with composition with template mixins. Nothing
particular wrong with this model but I think the D documentation
isn't clear about its intended use. Also the overlap with alias
this makes it more confusing.
More information about the Digitalmars-d
mailing list