Shallow copy with hierarchical reference

class packet;
    rand int a;
    rand int b;
endclass

class test;
    rand packet p1;
    rand int c;
    rand int d;

    function new();
        p1 = new();
    endfunction

    function test copy(test t1);
        p1 = new() t1.p1;
        c = t1.c;
        d = t1.d;
    endfunction
endclass
    p1 = new() t1.p1;

Hi, Is this way of shallow copy with hierarchical reference valid?

In reply to yourcheers:

What happened when you tried it?