Oops - minor fix below (cut and paste from another example I had lying around...) Gordon Vreugdenhil wrote: > Don, > > Until a pure virtual method is overridden, all class types in > the inheritance chain must be abstract (i.e. be "virtual class"). > So derived classes may or may not override a pure virtual > method but if they don't, they must remain abstract. > > module top; > virtual class base; > pure virtual task t; > virtual task t2; > $display("in base::t2"); > endtask > endclass > > virtual class mid extends base; > endclass > > class bot extends mid; > task t; > super.t; "super.t" is illegal here since "t" is pure virtual in mid (and base). Gord. > $display("in bot::t"); > endtask > endclass > endmodule > > It would be an error if "mid" was not an abstract class > since the method "t" is still pure virtual in mid. Once > "bot" overrides "t", all methods have implementations and > "bot" is no longer required to be abstact. > > > If base::t was not pure, then "mid" would not have to > be abstract. The override in bot would still be valid. > > Basically the rule is that not specifying anything in > an intermediate class with respect to a method does not > impact the method inheritance from the base class > (pure virtual remains pure virtual, etc). > > Gord. > > > Don Mills wrote: > >> I have second question on the same train of thought that Kakoli >> presented. If a virtual base class contains a virtual method, then >> when the base class is extended, is the extended child class required >> to include the virtual method? Or is the virtual method only a >> prototype if the child class wished to use that method? I assumed >> that base class virtual methods were required to exist and be defined >> in extended classes, but that is not the case with all simulators. Is >> my understanding wrong here? >> >> >> dm >> >> >> -----Original Message----- >> From: Kakoli Bhattacharya >> Sent: Oct 19, 2006 6:07 AM >> To: sv-ec@server.eda.org >> Subject: [sv-ec] Query related to virtual methods in a class >> >> Hello, >> >> Consider the following code: >> >> virtual class Parent; >> integer it; >> int i; >> virtual task virtual_task(input reg rg); //This is the declaration >> endtask >> endclass >> >> class Child1 extends Parent; >> shortint si; >> longint li; >> virtual task virtual_task1(input reg rg1); >> endtask >> endclass >> >> class Child2 extends Child1; >> real r1; >> shortreal sr1; >> time t1; >> realtime rt1; >> task virtual_task(input reg rg1); // This is the redefinition >> it = rg1; >> i = rg1; >> si = rg1; >> li = rg1; >> endtask >> enclass >> >> My problem concerns the virtual task 'virtual_task'. >> When it has been declared in the parent class 'Parent' then it takes >> 'rg' as its argument. >> During its redefinition in the child class 'Child2' it takes 'rg1' as >> its argument. >> Is it necessary that the names of the variables also have to be >> identical? >> >> In LRM (1800-2005) Section 7.19 it is stated that "Virtual methods >> provide prototypes for subroutines, >> i.e., all of the information generally found on the first line of a >> method declaration: the encapsulation criteria, the type and number of >> arguments, and the return type if it is needed. >> Later, when subclasses override virtual methods, they must follow the >> prototype exactly." >> >> Prototype however do not mean identical variable name.But later on in >> the same section it is also stated that "Thus, all versions of the >> virtual method look identical in all subclasses" >> >> So what does the word 'identical' exactly mean overhere? Does it imply >> identical argument name also? >> >> Thanks, >> Kakoli >> >> >> >> ========================================================== >> Don Mills >> LCDM Engineering (Logic, Coding, & Design Methodology) >> mills@lcdm-eng.com www.lcdm-eng.com >> ========================================================== >> > -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.comReceived on Thu Oct 19 13:40:45 2006
This archive was generated by hypermail 2.1.8 : Thu Oct 19 2006 - 13:40:49 PDT