Professional Documents
Culture Documents
Polymorphism
Polymorphism
Polymorphism
Example
program main;
Shape s[2]; // Base handles.
Circle c = new;
Triangle t = new;
initial begin
c.radius = 3;
t.base = 9;
t.height = 12;
s[0] = c;
s[1] = t;
$display("The area of the circle is %0d.", s[0].area());
$display("The area of the triangle is %0d.", s[1].area());
end
endprogram : main