|
It really depends upon the architecture it is
fitting into, and whether you are likely to want to reuse such a structure in
other projects, or elsewhere in the same project. It would probably be
worthwhile you doing as OO anyway just to get a bit of practice in.
I would use a base class that had all of the
parent-child behaviour already implemented. For example:
// forward declare this so that we can declare the
TParentChildClass;
TParentChild = class;
TParentChildClass = class of
TParentChild;
// finish declaring this
TParentChild = class
private
FOwner : TParentChild;
FChildClass :
TParentChildClass;
FChildList : TList;
protected
function GetChild(Index : Integer):
TParentChild;
Property ChildClass : TParentChildClass read
FChildClass write FChildClass;
public
function AddChild :
TParentChild;
procedure RemoveChild(Index : Integer;
FreeChild : Boolean);
function ChildCount : Integer;
property Child[Index : Integer] :
TParentChild read GetChild;
end;
This is just a rough outline really, you will want
to add or change the functionality depending on what you want to
acheive.
Phil.
|
- RE: [DUG]: Best methods for representing a 3 dimensional ... Dave . Jollie
- RE: [DUG]: Best methods for representing a 3 dimensi... Leigh Wanstead
- Re: [DUG]: Best methods for representing a 3 dim... Dennis Chuah
- [DUG]: Best methods for representing a 3 dimensional... Dave . Jollie
- Re: [DUG]: Best methods for representing a 3 dim... Neven MacEwan
- Re: [DUG]: Best methods for representing a 3 dim... Phil Middlemiss
- Re: [DUG]: Best methods for representing a 3 dim... Dennis Chuah
