We have method overriding in system verilog, where the method in derived class can override the base class’s method. Both the methods should be of same name and same signature.
Do we have method overloading in system verilog? I mean does SV supports this concept?
If it is supported, can any body tell me the context in testbench or test development?
AFAIK “overloading” is not available in SV (unlike in VHDL for instance). Maybe if you explain what you need, we can help you find a way to do it in SV.
Overriding/overloading a method with the same signature can be the same as defining a virtual method. The term method overloading usually applies to methods with a different signature (i.e. different types or numbers of arguments).
I agree with Dave. Function overloading normally refers to the case where you have the same function name with different signatures.
A simple example in C++;
class C {
virtual void print(int x);
virtual void print(float y);
}
Note the same function “print” has two different signatures. This is a very useful feature. However this is not supported in
SystemVerilog as far as I know. Not sure if there are plans in the committee to support this in the future.
@Dave, I understand the method/function overriding in System verilog. I was looking for the scenario like Logie explained, where we have the two methods with same name but different signatures in SystemVerilog. So it is not supported for sure in systemverilog.
“We have method overriding in system verilog, where the method in derived class can override the base class’s method. Both the methods should be of same name and same signature”
Quote: Both the methods should be of same name and same signature.
Actually, I mentioned the above thing continuing the context of method overriding.
Static methods can be overloaded, that means a class can have more than one static method of same name. But static methods cannot be overridden, even if you declare a same static method in derived class it has nothing to do with the same method of base class…Source