copying the targets of pointers

Ali Çehreli acehreli at yahoo.com
Fri Jul 27 10:32:07 PDT 2012


On 07/27/2012 09:11 AM, monarch_dodra wrote:
 > This is going to sound stupid, but how do you have two pointers' targets
 > copy each other? since pointers are used like reference types, how do
 > you write the C++ equivalent of "*p1 == *p2"

The type must provide a function to make a copy of itself. Since arrays 
have .dup, that may be a suitable name:

    auto newObject = object.dup;

Ali



More information about the Digitalmars-d-learn mailing list