D vs C++ classes?

jmh530 john.michael.hall at gmail.com
Tue Jun 22 11:13:52 UTC 2021


On Tuesday, 22 June 2021 at 09:04:05 UTC, IGotD- wrote:
> [snip]
>
> 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.
> [snip]

Some other language had suggested something like below as a 
solution to the diamond problem
class A { void a() {} }
class B : A {}
class C : A { @disable a; }
class D : B, C {}

However, I was thinking what happens if you do something like
A ac = new C();

How would the compiler handle that?


More information about the Digitalmars-d mailing list