# How to generate one pointer for the parameterized class itself?

**URL:** <https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, parameterized-class\
**Created:** [December 14, 2015, 12:40pm UTC](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316 "2015-12-14T12:40:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aug\_com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/cab0a1/32.png) [@aug\_com](https://verificationacademy.com/forums/u/aug_com)\
**Post date:** [December 14, 2015, 12:40pm UTC](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316/1 "2015-12-14T12:40:53Z")

</div>

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?

---

<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:** [December 14, 2015, 8:54pm UTC](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316/2 "2015-12-14T20:54:04Z")

</div>

_In reply to [aug\_com](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316):_

Unfortunately, SystemVerilog treats

```verilog
a_xaction vr_cpy;

```

the same as

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

```

You need to add specific parameters.

```verilog
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.

---

<div class="post-metadata">

**Author:** ![aug\_com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/cab0a1/32.png) [@aug\_com](https://verificationacademy.com/forums/u/aug_com)\
**Post date:** [December 15, 2015, 12:54am UTC](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316/3 "2015-12-15T00:54:04Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-generate-one-pointer-for-the-parameterized-class-itself/31316/2):_

Hi dave\_59, your advice is really helpful.
