G
Guest
Hello, Newsgroupians!
I have, perhaps, a simple question regarding deep copy and the assignment
operator. I'm creating a class, and I would like to perform a deep copy of
all the members in an instance of the class. I know I can derive the class
from ICloneable and override the Clone() function. I do this, and I can
accurately create a deep copy of my class.
MyClass c1 = new MyClass(...);
MyClass c2;
c2 = c1.Clone();
This works -- of course -- but I would like to reduce the amount of typing
to just the simple...
c2 = c1;
Many of you may state that this is undesirable, for you may want a reference
at one time or another, but in this specific class whenever I do an
assignment operator, I ALWAYS want a deep copy. Is this possible? Thank you
all.
Trecius
I have, perhaps, a simple question regarding deep copy and the assignment
operator. I'm creating a class, and I would like to perform a deep copy of
all the members in an instance of the class. I know I can derive the class
from ICloneable and override the Clone() function. I do this, and I can
accurately create a deep copy of my class.
MyClass c1 = new MyClass(...);
MyClass c2;
c2 = c1.Clone();
This works -- of course -- but I would like to reduce the amount of typing
to just the simple...
c2 = c1;
Many of you may state that this is undesirable, for you may want a reference
at one time or another, but in this specific class whenever I do an
assignment operator, I ALWAYS want a deep copy. Is this possible? Thank you
all.
Trecius