Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: inheritance: constructors

by djantzen (Priest)
on Jun 24, 2002 at 23:22 UTC ( #176984=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub new {
      my ($class, @args) = @_;
    ...
        # then initialize the parts of the object that are unique to this 
    +class
        return bless($this, $class); # rebless to our class
      }
    
  2. or download this
    sub new {
      my ($class, %args) = @_;
    ...
      $$this{foo} = $args{foo};
      return bless($this, $class); # rebless to our class
    }
    
  3. or download this
    package SomeSuperclass;
    sub new {
    ...
         $this->_init(@_);
         return $this;
    }
    
  4. or download this
    package SomeSubclass;
    use base SomeSuperclass;
    ...
      $this->SUPER::_init($bar, $baz);
      $$this{foo} = $foo;
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-07-05 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls