Hi,
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:package A; use strict; use fields qw(id name); sub new { ... }
andpackage B; use strict; use base qw(A); use fields qw(addr phone city);
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 statementpackage C; use strict; use base qw(A); use fields qw(model type);
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.use 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.
---
Michael Stepanov aka nite_man
It's only my opinion and it doesn't have pretensions of absoluteness!
In reply to Cross reference between two classes and FIELDS by nite_man
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |