Thanks for your reply, Peter. I think I didn't label
my packages clearly for you, which likely makes a big
difference ;-) If this tidbit changes your reply, let
me know. Sorry about this, and thanks again!

> The B in your code uses an X to connect, not A. 
> Perhaps you're eliding too 
> much information.

package X;
sub new {
    my $proto=shift;
    my $specs=shift;
    my $class=ref($proto) || $proto;
    my $self={};
    $self->{connection}= X::connect($specs);
    return undef unless defined
$self->{$connection};
    bless ($self,$class);
    return $self;

package Y;
sub new {
     my $proto=shift;
    my $specs=shift;
    my $class=ref($proto) || $proto;
    my $self={};
     $self->{X} = X->new();
     $self->{connection}= $self->{X}->{connection};
     return undef unless defined
$self->{$connection};
     bless ($self,$class);
     return $self;



--- Peter Scott <[EMAIL PROTECTED]> wrote:
> At 05:36 AM 8/15/01 -0700, Blair Burns wrote:
> >Hi *,
> >
> >I am rather a beginner to Perl (and programming)
> but
> >am nevertheless faced with maintaining a complex OO
> >environment. Yikes! Anyway, here is my problem: I
> have
> >two classes whose constructors return a db handle.
> "A"
> >accepts parameters for user/password, while "B",
> >although it uses A to connect as well, does not
> >acccept any parameters, thus connecting only as
> root.
> 
> The B in your code uses an X to connect, not A. 
> Perhaps you're eliding too 
> much information.
> 
> >All the keen methods belong to the latter class,
> and
> >since I want to connect via CGI and display the
> >information they provide to the masses via their
> >browser, without them entering passwords, I need to
> >know how to use A's ability to connect with B's
> great
> >methods. I've heard of something called
> overloading,
> >but can this apply to constructors?
> 
> There's no function overloading in the C++ sense
> (not without using some 
> modules I'm not prepared to get into).  There is
> operator overloading, but 
> a constructor is not an operator.
> 
> >Or do I need a
> >whole new class, copying and pasting the stuff I
> need,
> >cmopletely undermining the OO philosophy? I know
> >better than to mess with the "black box".
> 
> Sometimes the black box needs messing with.  Without
> seeing more code it's 
> hard to tell, but perhaps you could get what you
> want without modifying 
> existing modules by subclassing B and overriding its
> constructor.  Cut and 
> paste the existing constructor and modify it to pass
> parameters.
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to