Re: Inheritance design issue
From: Lucas Tam (REMOVEnntp_at_rogers.com)
Date: 11/25/04
- Next message: Bob Hollness: "Re: Avoiding dupes when merging files"
- Previous message: Andy: "Re: How do I create a com object?"
- In reply to: Mark O'Flynn: "Inheritance design issue"
- Next in thread: Nak: "Re: Inheritance design issue"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Nov 2004 19:34:59 GMT
"Mark O'Flynn" <mark.oflynn@ozemail.com.au> wrote in
news:DIppd.337$Mp6.8217@nnrp1.ozemail.com.au:
> If Phone is changed in the Person object, this will not be reflected
> in the Manager object.
>
> It seems to me that this would be a common situation faces in OOP, so
> any advice on how I can get an inheritied object to maintain a
> reference to the base object's data, or how best to design a solution
> would be most appriciated.
I think you'll want to declare your manager phone property as "Shadows"
phone. This allows you to create an identically named proprety called
phone which won't override the base class property:
Shadows
Optional. Indicates that this property shadows an identically named
programming element, or set of overloaded elements, in a base class. You
can shadow any kind of declared element with any other kind. If you
shadow a property with another property, the arguments and the return
type do not have to match those in the base class property. A shadowed
element is unavailable from within the derived class that shadows it,
unless the shadowing element is inaccessible, for example if it is
Private.
Note You cannot specify both Overloads and Shadows in the same
property declaration.
To access the bass class data you'll need to provide a property to
access the bass class object (i.e. GetParentObject which will return
Mybase) or provide a property to access the bass class property (i.e.
GetPersonPhone).
MyBase
The MyBase keyword behaves like an object variable referring to the base
class of the current instance of a class. MyBase is commonly used to
access base class members that are overridden or shadowed in a derived
class. In particular, MyBase.New is used to explicitly call a base class
constructor from a derived class constructor.
It is invalid to use MyBase to call MustOverride base methods.
These are just ideas on the top of my head... and are untested. Maybe
someone with more OO experience can provide a better solution.
-- Lucas Tam (REMOVEnntp@rogers.com) Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
- Next message: Bob Hollness: "Re: Avoiding dupes when merging files"
- Previous message: Andy: "Re: How do I create a com object?"
- In reply to: Mark O'Flynn: "Inheritance design issue"
- Next in thread: Nak: "Re: Inheritance design issue"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|