-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
78 lines (61 loc) · 1.27 KB
/
Unit1.pas
File metadata and controls
78 lines (61 loc) · 1.27 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Generics.Collections;
type
{ TPessoa }
TPessoa = class
private
Fnome: string;
procedure Setnome(AValue: string);
public
property nome : string read Fnome write Setnome;
end;
{ TNFe }
TNFe<T: constructor> = class
FGeneric : T;
function PegaGeneric : T;
constructor create;
end;
TForm1 = class(TForm)
btnGeneric: TButton;
procedure btnGenericClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
ListaNum : TList<integer>;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TPessoa.Setnome(AValue: string);
begin
Fnome := AValue;
end;
{ TForm1 }
procedure TForm1.btnGenericClick(Sender: TObject);
var
vExemplo2 : TNFe<string>;
vNFe : TNFe<TPessoa>;
begin
vNFe := TNFe<TPessoa>.Create;
try
vNFe.FGeneric.nome := 'Fernando';
ShowMessage(vNFe.FGeneric.nome);
finally
vNFe.Free ;
end;
end;
{ TNFe }
function TNFe<T>.PegaGeneric: T;
begin
Result := FGeneric;
end;
constructor TNFe<T>.create;
begin
FGeneric := T.create;
end;
end.