Is it possible to pass in a default value when passing parameters by Type

I have a class that is widely reused similar to the following:

  virtual class my_reuse_class#(type A=int) extends uvm_component;

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunciton

    pure virtual function void my_function(A my_attribute);

  endclass

There is now need for more functionality and I want to be able to pass in additional typed parameters without hurting the backwards compatibility with previous usage. Is it possible to give a “pass by type parameter” a default value, so that older code will not need to be modified to work with the new class? For example:

  virtual class my_reuse_class#(type A=int, type B=int=0) extends uvm_component;

    function new(string name, uvm_component parent);
      super.new(name, parent);
    endfunction

    pure virtual function void my_function(A my_attribute, B my_new_attribute);

  endclass

  class my_old_class extends my_reuse_class(logic[1:0]);
    virtual function void my_function(A my_attribute);
      // do stuff 
    endfunction
  endclass

  class my_new_class extends my_reuse_class(logic[1:0], string);
    virtual function void my_function(A my_attribute, B my_new_attribute);
      // do more stuff 
    endfunction
  endclass

Thank you

In reply to julie.oliver:

What you are asking for is impossible because there is no way the “older code” could declare a class variable whose B type is a string. At some point you would want to construct a my_new_class object and assign its handle to a my_old_class variable and the base my_reuse_class type would not be the same.

There might be other ways of approaching this by making the second argument a policy class instead of trying to parameterize its type. It’s default value would simply be null.

In reply to dave_59:

Thank you Dave. I was afraid that was the case, but was hoping that by assigning the new input parameters to a default value that I could get around that.

I will go look up policy classes.

Cheers

In reply to julie.oliver:

The base class specialization issue is a problem even if you were not trying to add a second argument to my_function. It is independent of the virtual methods.