Parameterized class: specialization

In reply to Tudor Timi:

What do you mean with call ‘get_next_number(x)’? What function prototype would that have? How does it know if x was a real or complex?
The get_next_* function has to call the derived class ‘extra stuff’.

what does work for now is:

class C#(type T);
   T value;
   function doit(T x);
      if (type(T)==type(t_Real)) begin
        t_Real tmp;
        getNext_Real(tmp);
        $cast(x,tmp);
      end else if (type(T)==type(t_Complex))
        t_Complex tmp;
        getNext_Complex(tmp);
        $cast(x,tmp);
      end
   endfunction
endclass

But it doesn’t feel very elegant.