[fpc-pascal] private type and type compatibility
Xiangrong Fang
xrfang at gmail.com
Wed Oct 30 08:47:54 CET 2013
Hi All,
I have the following class:
type
generic TVector<T> = class
private type
TDataType = array of T;
private
FData: TDataType;
... ...
public
... ...
function Slice(APos: Integer = -1; ACount: Integer = -1): TDataType;
end;
The Slice() method return a portion of the data as a dynamic array.
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:
type
TIntVector = specialize TVector<Integer>;
var
iv: TIntVector;
ia: array of Integer;
begin
iv := TIntVector.Create;
... ...
ia := iv.Slice;
end.
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?
i.e. how does the type system work?!
Best Regards,
Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131030/646d088c/attachment.html>
More information about the fpc-pascal
mailing list