Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re (tilly) 1: Inheriting object data

by tilly (Archbishop)
on Feb 17, 2001 at 03:05 UTC ( [id://59030]=note: print w/replies, xml ) Need Help??


in reply to Inheriting object data

Erm, I don't see why you want two objects. Just create an object in class Foo::Bar by calling the new method that it inherits from Foo.

If you want to, you can actually give Foo::Bar a new() method which does some stuff and is a wrapper around SUPER::new (which is a "fake" method to get at your parent's new method).

Replies are listed 'Best First'.
Re: Re (tilly) 1: Inheriting object data
by archon (Monk) on Feb 17, 2001 at 03:12 UTC

    i must be missing something.. i thought i _was_ creating an object in class Foo::Bar by calling the new method that it inherits from Foo. however, that thought seems incongruous with "I don't see why you want two objects." are you saying i don't want to create an object from the base class? i suppose that is an option.

    i am open to any solution that lets me use the subclass with the data that i fed the base class without having to give this data to the base class.

      Just construct an object in Foo::Bar directly without making something in Foo first and pass it the data. That object "is-a" Foo as well.

      In other words my point is that the object you create in the base class Foo just seems to be a redundant object. It isn't used, it isn't necessary. I see no reason to not just lose it and then you have no problem left.

        ah, i see. in this example that i cooked up to demonstrate the problem it is not used. in my real program, it is.

        the base class has login and password info that all the subclasses use. the base class also has a login method.

        the effect i was trying to achieve was to only have to pass the data (login/password) once and have it stored in a core object from which all the derived objects inherited not only its methods, but object data. does that violate OO principles?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://59030]
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-20 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found