Partial override of a class

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

In reply to Peak25500:

Are A and C declared as virtual methods?

In reply to dave_59:

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?

In reply to Peak25500:

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 for more details about how inheritance works.

In reply to dave_59:

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