What is wrong with the following code.
program test;
class a;
const int i;
endclass : a
class b extends a;
function new();
i = 10;
endfunction : new
endclass : b
class c extends a;
function new();
i = 100;
endfunction : new
endclass : c
initial begin
b bo = new();
c co = new();
$display(bo.i, co.i);
end
endprogram : test
I get the following compile error
Invalid initialization of instance constant: 'i' cannot be initialized
more than once in constructor. There is a potential re-initialization
at statement : this.i = 10; Previous at: test.sv,9 Source info:
this.i = 10;