RE: [sv-ec] virtual methods

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Thu Jan 01 2009 - 02:31:22 PST
Thanks, I think I am getting the hang of this.

I don't see how the text I quoted from 8.19 was supposed to express this.

There are two more cases that I did not see explicitly described, unless I missed them.

In a case like this:

Leaf l = new;
Derived d = l;

1. From d, can I access a method M or property P that is defined in Leaf, but not in Derived? I understand that if M or P is defined in both Derived and then overriden in Leaf, then d.P (or M) gives me Derived::P (or M), not Leaf::P (or M), but is d.P (or M) legal if there is no Derived::P (or M)?

2. Declaring a method as virtual in Derived (e.g., pow()) means that d.pow() will give me Leaf::pow() instead of Derived::pow(). Is there any equivalent of a virtual method for properties? That is, if property P is defined in both Derived and Leaf, is there any way for d.P to give me Derived::P instead of Leaf::P? There does not seem to be.

Thanks,
Shalom



> -----Original Message-----
> From: David Jones [mailto:djones@xtreme-eda.com]
> Sent: Wednesday, December 31, 2008 6:49 PM
> To: Bresticker, Shalom
> Cc: sv-ec@server.eda.org
> Subject: Re: [sv-ec] virtual methods
>
> You're right. We do indeed get Derived::foo().
>
> Which just goes to show how confusing this can be to explain
> (but simple once you understand it).
>
> The task will be to come up with a good presentation for the next LRM.
>
> On Wed, Dec 31, 2008 at 11:41 AM, Bresticker, Shalom
> <shalom.bresticker@intel.com> wrote:
> > Hi,
> >
> >> d->foo(); // ditto. Here we must look up to pick up the
> >> definition in Base.
> >> l->foo(); // ditto.
> >
> > Since the reference types are Derived and Leaf,
> respectively, why don't we get Derived::foo() ?
> >
> > Thanks,
> > Shalom
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Jan 1 02:32:54 2009

This archive was generated by hypermail 2.1.8 : Thu Jan 01 2009 - 02:33:38 PST