# An interesting polymorphism behavior/mis-behavior?

**URL:** <https://verificationacademy.com/forums/t/an-interesting-polymorphism-behavior-mis-behavior/32332>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, virtual-polymorphism\
**Created:** [October 2, 2016, 6:22am UTC](https://verificationacademy.com/forums/t/an-interesting-polymorphism-behavior-mis-behavior/32332 "2016-10-02T06:22:45Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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 30, 2018, 7:16am UTC](https://verificationacademy.com/forums/t/an-interesting-polymorphism-behavior-mis-behavior/32332/7 "2018-12-30T07:16:42Z")

</div>

_In reply to [kernalmode1](https://verificationacademy.com/forums/t/an-interesting-polymorphism-behavior-mis-behavior/32332/6):_

In variant 2, A::showMsg is non-virtual. The code calling a.showMsg must behave as non-virtual because is has no knowledge the class will be extended. That means A::showMsg could have a completely different prototype from B::showMsg if you wanted (i.e. a different number of argument). But once B::showMsg is declared virtual, all derived methods are virtual and must have the same prototype.

---

_[View the full topic](https://verificationacademy.com/forums/t/an-interesting-polymorphism-behavior-mis-behavior/32332)._
