Linked list, printing looks destructive.
    Ali Çehreli 
    acehreli at yahoo.com
       
    Mon Apr 25 15:18:08 UTC 2022
    
    
  
On 4/25/22 03:48, Salih Dincer wrote:
 > It is also possible with the copy constructor of a struct. I don't know
 > how to do with class...
Classes don't have language provided construction because nobody needs 
it and in fact they have to protect themselves when a language provides 
it. (See, e.g. C++'s slicing problem: 
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-copy-virtual 
) [1]
In case you want to copy a class object, you must provide a function 
yourself, which may be called anything you want or 'dup' to match with a 
name used by D.
Ali
Off-topic rant: It frustrates me when C++ programmers shun D because it 
is "a language with reference types" as told to me by a well-known C++ 
speaker. I guess they should attempt to read C++'s core guidelines to 
understand how a polymorphic class makes it an accident to pass its 
objects by value.
    
    
More information about the Digitalmars-d-learn
mailing list