blob: c914f5fe19f541e8fccb94e539528193714dd85d (
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
45
46
47
48
49
|
program toperator11;
{$mode objfpc}{$H+}
{$apptype console}
type
TFoo = record
F: Integer;
end;
operator Inc(a: TFoo): TFoo;
begin
Result.F := a.F + 1;
end;
operator Dec(a: TFoo): TFoo;
begin
Result.F := a.F - 1;
end;
operator :=(a: TFoo): Integer;
begin
Result := a.F;
end;
operator explicit(a: TFoo): Integer;
begin
Result := a.F + 1;
end;
var
a: TFoo;
i: Integer;
begin
a.F := 1;
inc(a);
if a.F <> 2 then
halt(1);
dec(a);
if a.F <> 1 then
halt(2);
i := a;
if i <> 1 then
halt(3);
if Integer(a) <> 2 then
halt(4);
WriteLn('ok');
end.
|