Re: Object within an Object's Structure [message #71279] |
Wed, 09 June 2010 12:34 |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 6/9/10 1:12 PM, carl wrote:
> Hello,
>
> I am trying to make use of what OOP functionality IDL has, and I wish
> to have as an object variable another object of a different type.
>
> Is this possible? If so, how do I specify this?
>
> I have an object type orbitingBody, and want to make an object
> orbitingPair. Would this work? how would it be then coded in my init
> function?
>
> pro orbitingpair__define
> struct = { orbitingPair,
> planet: obj_new('orbitingbody', args)
> star: obj_new('orbitingbody', args)
> etc...}
> end
>
> thanks,
>
> Carl
For object's instance variables, the definition of the type of the
variable is done separately from the creation of the variable. So in
your case:
function orbitingpair::init
self.planet = obj_new('orbitingbody', args)
self.star = obj_new('orbitingbody', args)
return, 1
end
pro orbitingpair__define
define = { OrbitingPair, $
planet: obj_new(), $
star: obj_new() $
}
end
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|