How to generate one pointer for the parameterized class itself?

Class a_xaction #(int N_SZ = 40, F_SZ=100) extends a_original_c;
//a lot of members
extern virtual function a_original_c copy(a_original_c to=null);
endclass

function a_original_c a_xaction ::copy(a_original_c to=null);
a_xaction vr_cpy; // <<—Here is the question, I need a parameterized class itself.
if(to !=null) begin
if(!cast(vr_cpy, to) begin
$display(“ERROR!”); // The error will report when the b_xaction is used,in which the N_SZ is 50
end
end

endfunction : copy

typedef a_xaction #(.N_SZ(50)) b_xaction

So when I call the copy() for the b_xaction ,it will report the error.

And my question is : How to declare the vr_cpy in the copy function could avoid that?

In reply to aug_com:

Unfortunately, SystemVerilog treats

a_xaction vr_cpy;

the same as

a_xaction#( /* default parameter values */ ) vr_cpy;

You need to add specific parameters.

a_xaction #(N_SZ, F_SZ) vr_cpy;

. You may want to take a look at section 8.25.1 Class resolution operator for parameterized classes in the 1800-2012 LRM for related issues.

In reply to dave_59:

Hi dave_59, your advice is really helpful.