Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Help with objects.

by izut (Chaplain)
on Mar 14, 2006 at 13:10 UTC ( [id://536561]=note: print w/replies, xml ) Need Help??


in reply to Help with objects.

I think you're getting confused about OO patterns. You must ask yourself: will TestClass be a ConfClass or it will have a ConfClass? After you answered that question, you will be able to implement it. If TestClass will BE a ConfClass:

package TestClass; use base qw(ConfClass); sub new { my $class = shift; my $self = $class->SUPER::new(); # Initialize the superclass ConfC +lass here. ... # Do whatever you want. return $self; }

If TestClass HAS a ConfClass object, then it should be someway like this:

package TestClass; use ConfClass; sub new { my $self = {}; bless $self; $self->conf(ConfClass->new()); } sub conf { my ($self, $conf) = @_; $self->{'_CONF'} = $conf if $conf; return $self->{'_CONF'}; }

Igor 'izut' Sutton
your code, your rules.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-23 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found