Quantcast
Channel: Cadence Functional Verification Forum
Viewing all articles
Browse latest Browse all 1074

Is it a must to declare with keyword 'virtual' when define a task in a child class with the same name as its parent?

$
0
0

Look into the code as below, the task whoAmI() is not declared using 'virtual', but when calling it from class B, it actually get B's task executed. Then it seems that the 'virtual' keyword is not necessary here?

class A;

   task whoAmI();
      $display("This is A");
   endtask // whoAmI
  
endclass // A

class B extends A;

     task whoAmI();
        $display("This is B");
     endtask // whoAmI
endclass // B
  
B b = new();
b.whoAmI();


Viewing all articles
Browse latest Browse all 1074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>