comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Inheritance query
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Inheritance query [message #17776 is a reply to message #17640] Wed, 10 November 1999 00:00 Go to previous messageGo to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
"J.D. Smith" wrote:
>
> Bernard Puc wrote:
>>
>> Hello
>>
>> For the object programming gurus: I'm creating a class called data.
>> I'm then creating subclasses of data called type1, type2, etc. The
>> type1 class inherits the data class attributes. Now, is it possible to
>> inherit, lets say, the data::INIT method and somehow add to it? Or, do
>> I have to write an entirely new INIT method for type1 class which
>> incorporates the statements in the data::INIT method?
>
> By default, all methods are inherited. To add to the method, you need to "chain
> up" to the superclass, like this:
>
> function SubClass::Init,_EXTRA=e
> if (self->SuperClass::Init(_EXTRA=e) ne 1) then return,0
> ;;; do more stuff
> return,1
> end
>

One more tip: make good use of the _REF_EXTRA mechanism for chaining up to
methods which should return something:

pro SubClass::GetProperty,VALUE=val,_REF_EXTRA=e
val=self.value
SuperClass::GetProperty,_EXTRA=e
end

This allows the SuperClass's GetProperty Method to put things into variables for
return (like properties of the SuperClass, which aren't always just data
member!), impossible with the _EXTRA mechanism.

JD

--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDLSpecII: IDL Speed Survey Redux!
Next Topic: ATAN inconsistencies

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 01:40:21 PDT 2025

Total time taken to generate the page: 0.08154 seconds