I have tried this question in a couple of other places but the answers are far 
above my current level of understanding of oop - which is the level of very 
interested newbie - real newbie.  So here goes again.
 
 I make an empty (of data) perl object1 with an included method which can be 
called to put data into the hash inside this object. I can now call that method 
and insert data.  Simple OOP - it works.
 
 Now I make another empty object2 and inherit object1.  I can call the 
inherited method from object1 through object2 and it also works, but not like I 
assumed it would.
 
 I am trying to understand whether...
 
 I have two identical and totally separate objects, each independent of the 
other with the second being a copy of the first plus whatever might be added 
later - but nothing in this case.
 
 Or I have two objects and the second one "sees" (or calls, or views) the 
first.  It really doesn't matter except...
 
 The reason I am asking, is that the second object inherits the methods of 
object1, but doesn't inherit the data currently inside object1. If I call the 
add method in object1, ($object1->add_data)  it adds data to object1.  Since 
object1 is the parent that should be correct.  
 
 But that new data doesn't appear to object2.  In fact, object2 never sees data 
in object1 unless that data was put there by the new() constructor when the 
object was made.  And calling the add method ($object2->add_data) doesn't add 
data to object1 - it adds it to object2.
 
 I think I see why by tracing through the process.  When object2 inherits 
object1, it runs the initalize new() function of object1 and makes a new and 
empty object.  I can't find any example in my books about how to inherit an 
object without having the constructor in the inherited object run.  Or if it 
can be.
 
 Have I confused everybody?  I am.
 
 So, is data inheritable?  Or only methods?  I doubt that is correct since it 
would take away a lot of reason for inheriting in the first place.    
 
 OOP is a lot of fun and I can see where it would be great in a large project, 
but has a very steep start in the learning curve.
 
 CptKrf
 
  

                        
---------------------------------
Yahoo! Shopping
 Find Great Deals on Gifts at Yahoo! Shopping 

Reply via email to