# Importance of the clone( ) method

**URL:** <https://verificationacademy.com/forums/t/importance-of-the-clone-method/25472>\
**Category:** OVM\
**Tags:** OVM\
**Created:** [March 28, 2008, 11:34am UTC](https://verificationacademy.com/forums/t/importance-of-the-clone-method/25472 "2008-03-28T11:34:52Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 24, 2014, 9:16pm UTC](https://verificationacademy.com/forums/t/importance-of-the-clone-method/25472/7 "2014-02-24T21:16:43Z")

</div>

_In reply to [mseyunni](https://verificationacademy.com/forums/t/importance-of-the-clone-method/25472/7):_

```verilog
class base;
int p1;
  function void copy(base orig);
    this.p1 = orig.p1;
  endfunction
endclass
class ex_base;
  int p2;
  function void copy(base orig);
    super.copy(b);
    this.p2 = orig.p2;
  endfunction
endclass

base b1,b2;
ex_base eb1, eb2;
initial begin
   eb1 = new; eb2 = new();
   eb2.p2 = 5;
   b1 = eb1; b2 = eb2;
   b1.copy(b2); // p2 is not copied
   eb1.copy(eb2); // p2 is copied
end

```

Since copy() is not virtual, calling b1.copy() calls base::copy(), and the additional property p2 is not copied even though it exists in object referenced by b1.

---

_[View the full topic](https://verificationacademy.com/forums/t/importance-of-the-clone-method/25472)._
