Regarding Method Overriding / Polymorphism SystemVerilog

In reply to Chandrashekhar Goudar:
Sorry about hat I have fixed the code.

class A;
	int a=10;
  
	 virtual function void disp();
       $display("Base a=%d",a);
	endfunction
endclass
 
class B extends A;
	int a=20;
     
  function void disp();
    $display("Derived a=%d",a);
	endfunction
endclass
 
module tb();
  A a=new;
  B b;
  
	
  initial begin
    $cast(b,a);
    
    b.disp();               //
	$display("b.a=%d",b.a); // 
    a.disp();               //
    $display("a.a=%d",a.a); // 
           
    
  end
    
endmodule

I have a compilation error when I do a $cast(b,a) without doing “a=b”. Why is that? Then what is the point having $cast?
Error-[DCF] Dynamic cast failed
testbench.sv, 25
Casting of source class type ‘A’ to destination class type ‘B’ failed due to
type mismatch.
Please ensure matching types for dynamic cast