<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace">Hi All,<br><br>I have the following class:<br><br>type<br> generic TVector<T> = class<br> private type<br> TDataType = array of T;<br>
private<br> FData: TDataType;<br> ... ...<br> public<br> ... ...<br> function Slice(APos: Integer = -1; ACount: Integer = -1): TDataType;<br> end;<br><br></div><div class="gmail_default" style="font-family:courier new,monospace">
The Slice() method return a portion of the data as a dynamic array.<br><br>My question is, as I define TDataType as PRIVATE type, why it is still usable outside of the class? In the main program I did:<br><br></div><div class="gmail_default" style="font-family:courier new,monospace">
type<br></div><div class="gmail_default" style="font-family:courier new,monospace"> TIntVector = specialize TVector<Integer>;<br></div><div class="gmail_default" style="font-family:courier new,monospace">var<br></div>
<div class="gmail_default" style="font-family:courier new,monospace"> iv: TIntVector;<br></div><div class="gmail_default" style="font-family:courier new,monospace"> ia: array of Integer;<br></div><div class="gmail_default" style="font-family:courier new,monospace">
begin<br></div><div class="gmail_default" style="font-family:courier new,monospace"> iv := TIntVector.Create;<br> ... ...<br></div><div class="gmail_default" style="font-family:courier new,monospace"> ia := iv.Slice;<br>
</div><div class="gmail_default" style="font-family:courier new,monospace">end.<br><br></div><div class="gmail_default" style="font-family:courier new,monospace">This will assign a TDataType (is it TVector$TDataType or TIntVector$TDataType? I don't know) to an "array of Integer". Why this assignment works? <br>
<br></div><div class="gmail_default" style="font-family:courier new,monospace">i.e. how does the type system work?!<br><br>Best Regards,<br>Xiangrong<br></div></div>