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

There is no "parent object". There's just an object of the child class, which can also use methods defined in parent classes. What are you trying to accomplish?

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

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

Replies are listed 'Best First'.
Re: •Re: Objects: how to get parent object from child $self reference ?
by Anonymous Monk on Feb 28, 2004 at 02:18 UTC
    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.
      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.