D vs C++ classes?
mw
mingwu at gmail.com
Tue Jun 22 13:42:30 UTC 2021
On Tuesday, 22 June 2021 at 11:13:52 UTC, jmh530 wrote:
> 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?
That language is called Eiffel, and in such case, C become
abstract class, as I explained in this post:
https://forum.dlang.org/post/ztawxnwydbxiymcqvzhr@forum.dlang.org
https://forum.dlang.org/post/ztawxnwydbxiymcqvzhr@forum.dlang.org
More information about the Digitalmars-d
mailing list