Hi ,
could you please let me know why we need to mention name in super.new(name)
function new (string name);
super.new(name);
endfunction
Hi ,
could you please let me know why we need to mention name in super.new(name)
function new (string name);
super.new(name);
endfunction
In reply to srbeeram:
It depends on the constructor of the class you are extending from. SystemVerilog implicitly inserts a call to super.new() if you don’t put one in explicitly. However it the base class constructor has arguments without defaults, you must call super.new(supplied_arguments). For example
class base;
function new(string name="base"); // default supplied
endfunction
endclass
class ext1 extends base;
function new (int i);
// if no super.new, "base" is default argument
endfunction
endclass
class ext2 extends ext1;
function new();
super.new(2); // must have super.new
endfunction
endclass