Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

It's a dog, but what kind? (polymorphism , in Perl OO)

by blue_cowdawg (Monsignor)
on Mar 23, 2004 at 19:22 UTC ( [id://339131]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package dog;
    
    ...
    }
    
    1;
    
  2. or download this
    package dog::cocker;
    use dog;
    ...
    }
    
    1;
    
  3. or download this
    use dog::cocker;
    
    my $sasha=new dog::cocker;
    
  4. or download this
    package dog; 
    
    ...
        print "Woof!\n";
    }
    1;
    
  5. or download this
    use dog;
    
    ...
    
    $sasha -> bark();
    
  6. or download this
    package dog::samoyed;
    use dog;
    ...
    
    
    1;
    
  7. or download this
    .
    .
    ...
    .
    .
    .
    
  8. or download this
    # after the "my $self" line we add:
         %def_attrs=(
    ...
           $self->{$key} = $def_attrs{$key} if not $self->{key};
         }
    
  9. or download this
    package dog::cattle_dog;
    use dog;
    ...
    }
    
    1;
    
  10. or download this
    package dog; 
    
    ...
       print "tail wagging\n";
    }
    1;
    
  11. or download this
    use dog;
    use Data::Dumper;
    ...
    $moose->bark; $moose->wag_tail;
    $cosette->bark; $cosette->wag_tail;
    $frosty->bark; $frosty->wag_tail;
    
  12. or download this
    $VAR1 = bless( {
                     'voice' => 'yarf',
    ...
    tail over back
    yarf
    tail wagging
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://339131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found