Article View: borland.public.delphi.language.objectpascal
Article #129classes and collections
From: Andy
Date: Tue, 03 Feb 2004 18:10
Date: Tue, 03 Feb 2004 18:10
83 lines
3566 bytes
3566 bytes
Hello newsgroup,
please help a newbie. I've already searched the FAQ's, but didn't find an
answer.
I've got two classes and two collections:
TPerson = Class; //forward declaration for TPerson
TCommunication = Class; // forward declaration for TCommunication
TCommunications = Class;
// ========================================================
// T P E R S O N S c l a s s
// ========================================================
TPersons = class(TCollection)
private
function GetItem(Index : Integer) : TPerson;
Public
function Add : TPerson;
property Items[Index : Integer] : TPerson read GetItem; default;
// destructor Destroy; override;
end;
// ========================================================
// T P E R S O N c l a s s
// ========================================================
TPerson = Class(TCollectionItem)
private
fID : Integer;
fLastName : String;
fFirstName : String;
public
Communications : TCommunications;
Property ID : Integer read fID write fID;
Property LastName : String read fLastName write fLastName;
end;
// ========================================================
// T C O M M U N I C A T I O N S c l a s s
// ========================================================
TCommunications = class(TCollection)
private
function GetItem(Index : Integer) : TPerson;
Public
function Add : TCommunication;
property Items[Index : Integer] : TCommunication read GetItem;
default;
// destructor Destroy; override;
end;
// ========================================================
// T C O M M U N I C A T I O N c l a s s
// ========================================================
TCommunication = Class(TCollectionItem)
private
fID : Integer;
fPersonID : Integer;
fType : String;
fCountryCode : String;
fAreaCode : String;
fNumber : String;
Public
Property ID : Integer read fID write fID;
end;
How do I have to define the Person Class, if I want to have a
TCommunications Collection in it?
To make it clear, I want to do something like this
TPersons.items[1].Communications.Add TMyCommunication;
or
TPersons.items[3].Communications.Item[1].CountryCode:='001';
Thanks for your help guys!
Andy
Technical Details
Message-ID:
<bvonvf$8r9$05$1@news.t-online.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.esat.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d30,76ffd5b7f016436f,start X-Google-Attributes: gid109d30,public X-Google-ArrivalTime: 2004-02-03 10:07:14 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.esat.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: "Andy" <Anwendungsprogrammierer@web.de> Newsgroups: borland.public.delphi.language.objectpascal Subject: classes and collections Date: Tue, 3 Feb 2004 19:10:05 +0100 Organization: T-Online Lines: 86 Message-ID: <bvonvf$8r9$05$1@news.t-online.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.t-online.com 1075831603 05 9065 ffRFGjw6efUsSwe6 040203 18:06:43 X-Complaints-To: usenet-abuse@t-online.de X-ID: ZK398mZCZeGaQR3ybetCc2GJpUyITLIZYA2DCmL0DgctatodJa-rQp X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106