In reply to chr_sue:
In reply to UVM_LOVE:
Your $cast has to fail, because the classes you are casting are of different types.
Doing this :
module virtual_class;
initial begin
base_class b_c;
extended_class e_c;
extended_class2 e2_c;
e_c = new();
b_c = e_c;
$cast(e_c, b_c);
b_c.display();
end
endmodule
works perfectly, because e_c and b_c are now of the same type.
See an explanation also here:
Thanks SIr, I got it.
In Up-casting, I don’t need to assigning =. just I can casting between them.
But Down Casting, after assigning become same type, I can use $cast.