Polymorphism

In reply to dave_59:

In reply to verif_learner:
But the call to func2 inside DerivedC::func1 is bound at compile time to DerivedC::func2.
It might help to think of how the code looks if you move the functions outside the class

module poly_case4;
class BaseC;
extern virtual function void func1:
extern         function void func2:
endclass
function void BaseC::func1;
$display ("func1 in BaseC");
func2; // bound as BaseC::func2;
endfunction
function void BaseC::func2;
$display ("func2 in BaseC");
endfunction
class DerivedC extends BaseC;
extern virtual function void func1:
extern         function void func2: 
endclass
function void DerivedC::func1;
$display ("func1 in DerivedC");
func2; // bound as DerivedC::func2;
endfunction
function void DerivedC::func2;
$display ("func2 in DerivedC");
endfunction
BaseC    P1 ;
DerivedC P2 = new;
initial begin
P1 = P2;
P1.func1;
end
endmodule

Dave,

I still don’t get it.
If it is compile time binding then Base::func2 should be called as P1 is BaseC type.

Is it the case that since func1 is bound at run time, func2 is also bound at run time.
Since func1 is called as DerivedC::func1, is automatically calls DerivedC::func2 which is local to DerivedC.