D vs C++ classes?

jmh530 john.michael.hall at gmail.com
Tue Jun 22 14:54:42 UTC 2021


On Tuesday, 22 June 2021 at 13:42:30 UTC, mw wrote:
> [snip]
>>
>> 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

Thanks, the name of the language wasn't coming to me but I recall 
the prior discussion.

So if `C` becomes abstract, then the above line is prevented 
because you cannot instantiate an abstract class (correct? I 
can't test it on run.dlang.org right now and I'm not sure if it 
is `C c = new C()` that is prevented or this one). That's kind of 
limiting, no?

Does that have any separate implications for:
```d
A ad = new D();
B bd = new D();
C cd = new D();
D dd = new D();
```
My thought would be that just `cd` would be prevented.


More information about the Digitalmars-d mailing list