hugemx830202 Posted May 15, 2011 Report Share Posted May 15, 2011 Hi, From the UVM class reference manual, copy is deep copy, and clone is exact copy, so what does 'exact' copy mean? I guess clone is also deep copy, but the difference with copy(), is that clone() is virtual method, but copy() is not, need your confirm, thanks. BR MEIXIAO Quote Link to comment Share on other sites More sharing options...
Roman Posted May 15, 2011 Report Share Posted May 15, 2011 Hi MEIXIAO, The UVM clone method is used to provide a deep copy of an object. We can call clone() on any object, and it will use the clone() method of its actual class, without the calling code needing to know what that class is. Clone first allocates new memory for the object, then copies over each field to the new object. If a field is an object handle, then instead of copying the handle (which would do a "Shallow" copy) you would call fieldname.clone() to recursively allocate memory for that field (a "Deep" copy). Quote Link to comment Share on other sites More sharing options...
dave_59 Posted May 16, 2011 Report Share Posted May 16, 2011 clone() means construct followed by a call to copy(). clone() is virtual so that you can construct the same object type as the one you started with. clone() calls copy() to perform a deep copy of the object type you just created. The copy() method by itself just copies class member values from one object to another. Normally, the copy() method only copies the class members for the current class type, then it calls super.copy() to copy the class members of the base class. Quote Link to comment Share on other sites More sharing options...
nicolbiden Posted August 8, 2015 Report Share Posted August 8, 2015 An object copy is a process where a data object has its attributes copied to another object of the same data type. In .Net Shallow copy and deep copy are used for copying data between objects. More about.......Shallow copy and deep copy Biden Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.