The code is as follows:
class sn_oops #(type A = int);
A data;
task set(int i);
data = i;
$display("The value of data is --> %0d",data);
endtask: set
function int get();
return data;
endfunction: get
endclass: sn_oops
class sn_oops_ch #(type B = int) extends sn_oops;
B data;
function super_keyword(int val);
super.data = val;
$display("the value of data in parent class is --> %d",super.data);
$display("the value of data in child class is --> %d",data);
endfunction: super_keyword
endclass: sn_oops_ch
//declaration of base class handles
sn_oops #(bit[2:0]) sn_h1;
// sn_oops #($cast(A, string)) sn_h2;--------------------->>>>>>> I TRIED CASTING HERE AS WELL BUT ERROR COMES
sn_oops #(byte) sn_h2;
sn_oops #(integer) sn_h3;
sn_oops sn_h4;
module main;
initial begin
//creation of class handles
sn_h1 = new();
sn_h2 = new();
sn_h3 = new();
sn_h4 = new();
// accessing class methods set/get;;;
sn_h1.set(10); //out of bound values but no error occurs
$display("the value of sn_h1 is %p",sn_h1);
sn_h2.set(270); //out of bound values but no error occurs
$display("the value of sn_h2 is %p",sn_h2);
sn_h3.set($random);
$display("the value of sn_h3 is %p",sn_h3);
$display("--------------------------------------------------------");
sn_h4.set(20);
$display("accessing class methods using set and get methods\n");
$display("Value of datamember 'data' = %d",sn_h4.get());
$display("--------------------------------------------------------");
end
endmodule