Re: multiple inheritance and instance data?



On Thu, 29 Mar 2007 14:12:54 +0100, bugbear wrote:
I would like to have a class which has the behaviour
of 2 more primitive classes.
[...]
But I can't see, if BOTH parent classes
have constructors that return a blessed
object (e.g. a the typical hash reference),
what I'm meant to do in my child
class.

It's not that both parent constructors return blessed objects that's the
problem (what else would they do?).

It's whether the parent constructors do anything besides creating empty
blessed hashrefs.

That's why it's a best practice for constructors to create empty objects
and nothing else.

You write a constructor in the child that blesses an object into your
child class. Then you have to inspect the constructors of your parents to
see what they're doing. If they both follow best practice, you need do
nothing else. If one of them is well behaved and the other isn't, you can
instead call the constructor on the not-well-behaved one and then rebless
the returned object into your class. If they're both not well behaved,
you probably have to cut and paste.

This is one of the uglier things about Perl O-O.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

.



Relevant Pages

  • how do I pass a parameter or argument from one windows form to another?
    ... all of which are mdi child forms to the applications MDI Parent form. ... I'm sure it has something to do with constructors, ... this value to form2 will be greatly appreciated. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Constructor call constructor
    ... The constructors with minder parameters are only "shortcuts" for the full constructor ... The only problem comes when you introduce inheritance where the child ...
    (microsoft.public.dotnet.languages.csharp)