blob: b94b745670543dfd0f0607b2b0f689c6e0e013bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{$mode objfpc}{$h+}
type
generic TNode<T> = class
public
type
PT = T;
private
var
Data: T;
public
constructor Create;
destructor Destroy; override;
end;
TTNodeLongint = specialize TNode<Longint>;
TTNodeString = specialize TNode<String>;
constructor TNode.Create;
begin
end;
destructor TNode.Destroy;
begin
inherited Destroy;
end;
function GetIntNode: TTNodeLongint.T;
begin
result := 10;
end;
function GetStringNode: TTNodeString.PT;
begin
result := 'abc';
end;
begin
writeln(GetIntNode);
writeln(GetStringNode);
end.
|