good chemistry is complicated,
and a little bit messy -LW
Cross reference between two classes and FIELDSby nite_man (Deacon)
|on Sep 26, 2006 at 08:14 UTC||Need Help??|
nite_man has asked for the wisdom of the Perl Monks concerning the following question:
Recently I faced with following problem in the project which I develop. Let's say I have three classes: A, B and C. A is a base class for B and C and contains common fields:
Classes B and C inherit class A:
As I understand when I create an object B it should inherit properties from the base class - id and name. Sure, it works fine till I need to create inside object B object C and and vice versa. But to do that I have to add statement
into class B and and vice versa. Right after that the problems start. When I create a new object B it doesn't contain thr properties from the base class. The same for object C.
I "solved" it using require instead of use. Another possibility make preloading all custom modules before use it. Any others ideas or suggestions?
Thanks in advance.Updated: fixed class C definition.
It's only my opinion and it doesn't have pretensions of absoluteness!