type Cl = class a:integer; constructor Create(b:integer); procedure SetVal(b:integer); function GetVal:integer; procedure GetPrev; end;
constructor Cl.Create(b:integer); begin a := b; end;
procedure Cl.SetVal(b:integer); begin a := b; end;
function Cl.GetVal:integer; begin GetVal := a; end;
procedure Cl.GetPrev; var Pr, i:integer; begin writeln('Три предыдущих'); Pr := Pred(a); for i := 1 to 3 do begin writeln(Pr, ' '); Pr := Pred(Pr) end; end;
var Obj:Cl; begin Obj := Cl.Create(5); Obj.GetPrev; writeln; Obj.Destroy; end.
Answers & Comments
type Cl = class
a:integer;
constructor Create(b:integer);
procedure SetVal(b:integer);
function GetVal:integer;
procedure GetPrev;
end;
constructor Cl.Create(b:integer);
begin
a := b;
end;
procedure Cl.SetVal(b:integer);
begin
a := b;
end;
function Cl.GetVal:integer;
begin
GetVal := a;
end;
procedure Cl.GetPrev;
var
Pr, i:integer;
begin
writeln('Три предыдущих');
Pr := Pred(a);
for i := 1 to 3 do
begin
writeln(Pr, ' ');
Pr := Pred(Pr)
end;
end;
var
Obj:Cl;
begin
Obj := Cl.Create(5);
Obj.GetPrev;
writeln;
Obj.Destroy;
end.