module grand;
class parent;
task a;
$display(parent);
endtask
endclass
class child extends parent;
task a;
$display(child);
endtask
endclass
initial begin
parent p1=new;
child c1=new;
endmodule
How to call parent task using child handle with out super keyword…?
In reply to gangaraju@m:
new created the class handle p1 and c1. by copying the class handle c1 to p1 .
p1 = c1 ;
p1.a will call the parent task. however similar line in polymorphysim will call child task provided the task are virtual in parent/base class.
Hi,
i want to call parent task using child handle ..like (c1.a);
not p1.a.
In reply to gangaraju@m:
That cannot be done. You have hidden the parent task a from the child by overriding it. You must use super.a from the child class, or upcast to a parent class variable.