# Using %p after Upcasting

**URL:** <https://verificationacademy.com/forums/t/using-p-after-upcasting/35870>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Using-p-after-UpCasting\
**Created:** [March 20, 2019, 11:19am UTC](https://verificationacademy.com/forums/t/using-p-after-upcasting/35870 "2019-03-20T11:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanshuvalecha](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/97f17d/32.png) [@himanshuvalecha](https://verificationacademy.com/forums/u/himanshuvalecha)\
**Post date:** [March 20, 2019, 11:19am UTC](https://verificationacademy.com/forums/t/using-p-after-upcasting/35870/1 "2019-03-20T11:19:32Z")

</div>

Hello everyone ,

I have a small code ::

```verilog

module Main ;

class Base 

rand bit [1:0] a ;

endclass

class Ext extends Base ;

rand bit [1:0] b;

endclass

Ext e ;
Base b ;

initial begin

e = new() ;

b = e ; // Up-Casting

if ( b.randomize() ) // randomize() is Virtual 
$display(" b is %p ",b);

end

endmodule

Should the Output Ideally have 2 Properties ( a && b ) OR Only 1 ( Only a ) ?? 

 I tried this on different Simulators and got 2 Different Results

```

Thanks in advance ,

Himanshu V

---

<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:** [March 20, 2019, 4:13pm UTC](https://verificationacademy.com/forums/t/using-p-after-upcasting/35870/2 "2019-03-20T16:13:17Z")

</div>

_In reply to [himanshu valecha](https://verificationacademy.com/forums/t/using-p-after-upcasting/35870):_

The LRM defines %p for printing aggregate types as an assignment pattern. Classes are not considered aggregate types and does not define their use with assignment patterns. Some tools allow the use of %p with classes as a debugging aid, but the output is not defined. This is a tool specific issues and this forum is not for discussing those kinds of issues. Please contact your tool vendor.
