Inheritence question

Discussion in 'Perl' started by Doug Nichols, Feb 19, 2004.

  1. Doug Nichols

    Doug Nichols Guest

    I have a program where I create an class and pass a hash:

    x.pm
    package x;

    sub new {
    my $object = shift;
    my $self = ((@_ == 1) ? shift(): { @_ });
    return (bless $self, $object);
    }
    1;


    I also have another class y that I would like x to inherit, but I
    cannot seem to get the syntax correctly to do all things.

    y.pm
    package y;
    sub new {
    my $self = shift;
    $self = { MYX => 'HELLO', MYOMY => 'GOODBYE', }
    bless $self;
    return $self;
    }
    1;

    Can some one give me a hint?

    Thanks
    dn
     
    Doug Nichols, Feb 19, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. krzyber
    Replies:
    1
    Views:
    310
    Josh Martin
    Nov 20, 2003
  2. Sean Bright
    Replies:
    2
    Views:
    444
    Sean Bright
    Dec 17, 2003
  3. Michael C. Starkie

    multiple inheritence question

    Michael C. Starkie, Aug 14, 2003, in forum: C++
    Replies:
    4
    Views:
    336
    Senthilvel Samatharman
    Aug 14, 2003
  4. Replies:
    8
    Views:
    288
    Roedy Green
    Jan 5, 2008
  5. Catherine Heathcote

    Question about inheritence

    Catherine Heathcote, Jul 22, 2008, in forum: Python
    Replies:
    5
    Views:
    267
    Lawrence D'Oliveiro
    Jul 25, 2008
Loading...

Share This Page