# Partial override of a class

**URL:** <https://verificationacademy.com/forums/t/partial-override-of-a-class/33625>\
**Category:** OVM\
**Tags:** Inheritance, function, OVM, class, override\
**Created:** [October 18, 2017, 12:16pm UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625 "2017-10-18T12:16:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peak25500](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@Peak25500](https://verificationacademy.com/forums/u/Peak25500)\
**Post date:** [October 18, 2017, 12:16pm UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/1 "2017-10-18T12:16:08Z")

</div>

Hi guys,

Here is my problem:  
I have a class BaseClass that I extend to DerivedClass.  
In BaseClass, I have three function that are A, B and C. Function A calls B which itself calls C.  
In DerivedClass I have overriden functions A and C to A\_ and C\_.  
When I’m running simulation, A\_ calls B which then calls C while I’d like to call C\_.  
Is there a way to do so?  
For now, as a workaround, I just copied B to DerivedClass.

Thanks in advance,  
Johan

---

<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:** [October 18, 2017, 3:32pm UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/2 "2017-10-18T15:32:40Z")

</div>

_In reply to [Peak25500](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625):_

Are A and C declared as virtual methods?

---

<div class="post-metadata">

**Author:** ![Peak25500](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@Peak25500](https://verificationacademy.com/forums/u/Peak25500)\
**Post date:** [October 20, 2017, 12:53pm UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/3 "2017-10-20T12:53:06Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/2):_

Hi Dave,

Thanks for your reply and sorry for my delay to answer…  
In fact A and C are not declared as virtual. They are normally declared in BaseClass and just redefined in DerivedClass with A\_ and C\_.

If I understand well, I shall declare them as virtual in BaseClass? Shall them be empty in BaseClass or they can have a description there?

---

<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:** [October 20, 2017, 5:34pm UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/4 "2017-10-20T17:34:23Z")

</div>

_In reply to [Peak25500](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/3):_

Yes, they need to be virtual to accomplish what you describe. And since you already said that you have a BaseClass method A that calls B, it cannot be empty.  
Please see my [SystemVerilog OOP course](https://verificationacademy.com/topics/systemverilog/systemverilog-oop-for-uvm-verification/) for more details about how inheritance works.

---

<div class="post-metadata">

**Author:** ![Peak25500](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@Peak25500](https://verificationacademy.com/forums/u/Peak25500)\
**Post date:** [October 23, 2017, 8:57am UTC](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/5 "2017-10-23T08:57:38Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/partial-override-of-a-class/33625/4):_

Thanks Dave!  
I’ll have a look at your course and try to solve my problem.
