Cannot get this C++ example migrated to D

Ali Çehreli acehreli at yahoo.com
Sun Apr 16 08:38:55 UTC 2023


On 4/16/23 00:46, Skippy wrote:

 > I wish D had value type classes as well.

That cannot work due to the slicing problem.

C++ cannot have value type classes either for the same reason. The 
difference there is that the enforcement is by guidelines (e.g. "never 
pass class objects by value to functions", not by language).

If you want class objects on the stack, you have two options:

- The scope keyword

- The scoped template from Phobos

Ali



More information about the Digitalmars-d-learn mailing list