# Can child\_handle cast to parent\_handle using $cast(c\_h,p\_h), if parent\_handle is already not pointing child object and pointing to parent\_handle?

**URL:** <https://verificationacademy.com/forums/t/can-child-handle-cast-to-parent-handle-using-cast-c-h-p-h-if-parent-handle-is-already-not-pointing-child-object-and-pointing-to-parent-handle/40232>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, class-handle\
**Created:** [April 4, 2022, 6:03am UTC](https://verificationacademy.com/forums/t/can-child-handle-cast-to-parent-handle-using-cast-c-h-p-h-if-parent-handle-is-already-not-pointing-child-object-and-pointing-to-parent-handle/40232 "2022-04-04T06:03:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jkpatel](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/77aa72/32.png) [@jkpatel](https://verificationacademy.com/forums/u/jkpatel)\
**Post date:** [April 6, 2022, 4:23am UTC](https://verificationacademy.com/forums/t/can-child-handle-cast-to-parent-handle-using-cast-c-h-p-h-if-parent-handle-is-already-not-pointing-child-object-and-pointing-to-parent-handle/40232/4 "2022-04-06T04:23:35Z")

</div>

Thanks a lot Dave

Another follow up doubt,

B // Base class  
E // Extended class from B  
EE // Extended class from E

E e\_h ;  
B b\_h ;  
EE ee\_h ;

**case #1**  
ee\_h = new(); // instance created  
b\_h = ee\_h ; // legal  
$cast(e\_h,b\_h); // Is this also Valid ? Any runtime error ?

**case #2**  
e\_h = new(); // instance created  
b\_h = e\_h ; // legal  
$cast(ee\_h,b\_h); // Is this also Valid ? Any runtime error ?

If extended class handle pointing to base\_class handle which is already pointing to same extended class handle, it will work but what if base class handle is pointing to one level up(case#2) or one level down(case#1).

Please clarify.

---

_[View the full topic](https://verificationacademy.com/forums/t/can-child-handle-cast-to-parent-handle-using-cast-c-h-p-h-if-parent-handle-is-already-not-pointing-child-object-and-pointing-to-parent-handle/40232)._
