BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

defining classes

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Andy
Guest





PostPosted: Tue Feb 03, 2004 1:01 pm    Post subject: defining classes Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.