Jonathan, The whole class C becomes visible in the program by way of the import. Class B is not visible in the program PP. B b will not work. Because C is a derived class of B, any members/methods inherited from the base class B are visible through the class C in the program. For example: c.M and c.L are visible. If you had a static member or a method inside class B, those would be visible as well. Francoise ' -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Jonathan Bromley Sent: Tuesday, February 13, 2007 10:13 AM To: sv-ec@eda.org Subject: [sv-ec] Derived classes and package imports This is probably a really stupid question, but it has me a little confused. Suppose I have a base class declared in a package: package P; class B; logic L; endclass : B endpackage : P and then I want an extension of B but I don't want to modify the original package's source code. So I write a new package: package Q; import P::*; // to get definition of B class C extends B; logic M; endclass : C endpackage : Q So far, so good; but now I try to use this: program PP; import Q::*; // gets C, but no chained import of P C c = new; // OK initial begin $display(c.M); // definitely OK $display(c.L); // is this OK? I guess so. end initial begin B b; // can I do this? I guess not. b = c; // typical upcast end endprogram : PP In other words: If I import a package containing a definition of a class derived from a class it imports from another package, how much of the base class definition can I see? Usual apologies in advance if this is something obvious I should have known already. -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 Email: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Tue Feb 13 09:29:57 2007
This archive was generated by hypermail 2.1.8 : Tue Feb 13 2007 - 09:30:09 PST