Copy constructor in D. Why it is necessary to have it.

BCS ao at pathlink.com
Tue Sep 30 13:38:17 PDT 2008


Reply to bearophile,

> Eldar Insafutdinov:
> 
>>>> auto itCopy = it.clone();
>>>> 
>> Why copy it manually if language tends to do it so by providing
>> appropriate keyword. I should only write a copy constructor for my
>> data and let to do the rest to the compiler.
>> 
> In D all objects are managed by reference.

BTW note that structs ARE pass by value.





More information about the Digitalmars-d mailing list