in reply to •Re: Objects: how to get parent object from child $self reference ?
in thread Objects: how to get parent object from child $self reference ?

Hi,

I'd like to have one instance of parent class for communication with serial port. Now child instances beside their own data also contribute to "global" send/receive queue in parent class. Now I have method in parent instance that deals with this queue. Method is inherited into child instances and when I call it - I get reference to child object, but would like to perform operations on parent instance' queue.

Now I would like somehow to get to reference of parent instance from reference of child instance that got into method. How to do this ?

Thanks,

Robert.
  • Comment on Re: •Re: Objects: how to get parent object from child $self reference ?

Replies are listed 'Best First'.
•Re: Re: •Re: Objects: how to get parent object from child $self reference ?
by merlyn (Sage) on Feb 28, 2004 at 02:24 UTC
    You probably don't have an "IS-A" relationship then, but rather a "HAS-A" relationship. One instance of one class (your "parent class") owning a bunch of other specialized classes (your "child class").

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Hi,

      Sorry for my dumbness, but this still doesn't help me a lot. I'd just like to know if I have reference to instance, can I somehow get reference to parent instance and how?

      Thanks,

      Robert.