Why structs and classes instanciations are made differently ?

Houdini via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 24 08:45:29 PDT 2017


On Monday, 24 July 2017 at 15:41:33 UTC, Steven Schveighoffer 
wrote:

> Because types with inheritance generally don't work right if 
> you pass by value (i.e. the slicing problem).
>
> structs don't support inheritance or virtual functions, so they 
> can be safely passed by value.

But in C++, we pass them by reference also to avoid copies (const 
&).
The potential polymorphic usage is not the only point to consider.



More information about the Digitalmars-d-learn mailing list