Hi
I believe that if a function is declared virtual in at least one class, then it is considered virtual in all its extended and superclasses?
example-
class A; function amI;endfunction; endclass;
class B extends A; function amI;endfunction; endclass;
class C extends B; virtual function amI;endfunction; endclass; //virtual here
class D extends C; function amI;endfunction; endclass;
Q1-So, in the above code, no matter which class variable I use, the function will be called based on the object type(polymorphism), right?
What happens if the class is like a tree? for example-
class A; function amI;endfunction; endclass;
class B extends A; function amI;endfunction; endclass;
class C extends A; virtual function amI;endfunction; endclass; //changed here
class D extends C; function amI;endfunction; endclass;
Q2-Does polymorphism work between objects of A and B, I think it shouldn’t.
Q3-I was also wondering if it is safe to assume that pretty much all user available UVM functions are declared virtual in uvm package? for example, all phases (build_phase, connect_phase, etc…), do_copy, do_compare, convert2string, response_handler? If yes, can you think of any function which might be declared virtual?
Thanks in advance!