 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andy Guest
|
Posted: Tue Feb 03, 2004 1:01 pm Post subject: defining classes |
|
|
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.Communications.Add TMyCommunication;
or
TPersons.Communications.Item[1].CountryCode:='001';
Thanks for your help guys!
Andy
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|