Below is my example of polymorphism example. my expected results are not matching with the simulated one.
after reading LRM also I am not getting a crystal clear explanation about the simulated results.
Can any body help?
Expected results:
Inside child class:: value of a:-> 100
Inside Parent class:: value of a:-> 10
class base;
int a=10;
task display ();
$display(" Inside Parent class:: value of a:-> %0d", a);
endtask
endclass
class child extends base ;
task display ();
a =100;
$display(" Inside child class:: value of a:-> %0d",a);
endtask
function new();
super.new();
endfunction
endclass
module main ;
child my_child;
base my_base;
initial
begin
my_child = new();
my_base = my_child;
my_child.display();
my_base.display();
end
endmodule
Simulated results
Inside child class:: value of a:-> 100
Inside Parent class:: value of a:-> 100