- Код: Выделить всё
program Untitled;
uses
SysUtils;
type
TItems = record
id: integer;
name: string;
end;
T1 = class
procedure add(p: Pointer);
function getRecord: Pointer; virtual;
end;
T2 = class(T1)
t: TItems;
function getRecord: Pointer; override;
end;
procedure T1.add(p: pointer);
var
f: FILE;
begin
assignfile(f,'data.txt');
reset(f);
write(f, getRecord^); ??????????????????
close(f);
end;
function T1.getRecord: pointer;
begin
result := NIL;
end;
function T2.getRecord: pointer;
begin
result := @t;
end;
begin
writeln('Hello');
readln;
end.
Почему fpc дает ошибка здесь : write(f, getRecord^);
f: FILE не может. Нужно было FILE of ...
Дельфи этот компилирует.