In reply to mseyunni:
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.