in reply to Re: Point me in the right direction with OO inheritance and static variables
in thread Point me in the right direction with OO inheritance and static variables

Thanks! How does the child object "know" which class is the parent? (I hope my terminology is correct)

In other words, when i'm creating an object in the class which is inheriting the attributes, how does it know where SUPER points?

Thanks again for your help!

  • Comment on Re^2: Point me in the right direction with OO inheritance and static variables

Replies are listed 'Best First'.
Re^3: Point me in the right direction with OO inheritance and static variables
by choroba (Cardinal) on Sep 02, 2014 at 10:21 UTC
    In the child class, you specified
    use parent 'Parent::Class';

    right? See parent.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^3: Point me in the right direction with OO inheritance and static variables
by tobyink (Canon) on Sep 02, 2014 at 10:23 UTC

    The child class has a package variable called @ISA which tells it the parent class. This is an array because multiple inheritance is supported.

    package Child { require Parent; our @ISA = "Parent"; }

    For some reason, setting @ISA directly like that is not very fashionable, and a lot of people prefer to use a module like base, parent, or superclass to do so. Using one of those modules ensures that @ISA gets set at compile-time rather than run-time, though in practice this feature of them is almost never important.