Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inheritance

Status
Not open for further replies.

sancho1980

Technical User
Nov 25, 2005
15
DE
Hi!
I have made the following 3 definitions in one unit:

type
TEntry = class
private
FTarget: WideString;
FSource: WideString;
public
property Source: WideString read FSource write FSource;
property Target: WideString read FTarget write FTarget;
end;

type
PEntry = ^TEntry;

type
TVocabularyList = class(TList)
private
public
function LoadFromFile(FileName: String): Boolean;
end;

Now I'm trying to use them in another but the inheritance from TList in TVocabularyList doesn't seem to work properly, at least the following assignment does not compile, does anybody have a clue why?

var
TMemoQuestion: TMemo;
...
...
TMemoQuestion.Text := TMemoQuestion.Text + (^((PEntry)VocabularyList.Items)).Source;

Cheers,
Martin
 
You must instantiate your classes in order to use them.

Code:
var
  MemoQuestion: TMemo;
  MyList: TVocabularyList;
begin
  MemoQuestion := TMemo.Create;  // instantiate
  MyList := TVocabularyList.Create;  // instantiate
  MemoQuestion.Text := MemoQuestion.Text + MyList.Items[i].Source;
  ...
  MyList.Free;  // delete object and free memory
  MemoQuestion.Free;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top