On Thu, 7 May 2015, aradeonas wrote:
Hi,
I have a record and it has some value and a value with type of that record it self like this
example but compiler wont allow me to do this and give "Type "TExampleRecord"
is not
completely defined" error,and I dont want to use class and keep creating and
destroying it,they will be some simple record.
//Works with class
TExample=class
s:string;
E:TExample;
end;
//Doesn't work with record
TExampleRecord=record
s:string;
ER:TExampleRecord;
end;
You can never do this with records, it would recurse infinitely.
It works with a class, since a class is in fact just a pointer.
You must do
PExampleRecord=^TExampleRecord;
TExampleRecord=record
s:string;
ER:PExampleRecord;
end;
and allocate the record on the heap.
Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus