Почему я не могу напрямую вызвать метод класса ? ClassName.MethodName ? Просто интересно.
{$N+}
{$mode objfpc}
unit Polinom;
interface
type
TFloat = Double;
TCoeff = TFloat;
TCoeffs = array of TCoeff;
TPolinom = class
public
constructor Create(const n: Word);
destructor Destroy;
procedure ReadCoeffs;
procedure PrintCoeffs(const c: TCoeffs);
function GetDerivative(const c: TCoeffs): TCoeffs;
function GetCoeffs: TCoeffs;
property C: TCoeffs read GetCoeffs;
private
coeffs: TCoeffs;
end;
implementation
constructor TPolinom.Create(const n: Word);
begin
SetLength(coeffs, n + 1);
end;
destructor TPolinom.Destroy();
begin
SetLength(coeffs, 0);
end;
function TPolinom.GetCoeffs: TCoeffs;
begin
result := coeffs;
end;
procedure TPolinom.ReadCoeffs;
var
i: Integer;
begin
for i := 0 to Length(coeffs) - 1 do begin
write('x^', i, ' * ');
readln(coeffs[i]);
end;
end;
function TPolinom.GetDerivative(const c: TCoeffs): TCoeffs;
var
i: Integer;
begin
SetLength(result, Length© - 1);
for i := Length© - 1 downto 1 do
result [i - 1] := c[i] * i;
end;
procedure TPolinom.PrintCoeffs(const c: TCoeffs);
var
i: Integer;
begin
for i := 0 to Length© - 1 do
writeln('c[', i, ']=', c[i]:2:1);
end;
begin
end.
uses Crt, Polinom;
var
P: TPolinom;
degree: Integer;
test: TCoeffs;
begin
clrscr;
write('Введите степень полинома : '); readln(degree);
P := TPolinom.Create(degree);
P.ReadCoeffs;
test := P.C;
TPolinom.PrintCoeffs(test); // <---------------- Вот так нельзя делать ?!
P.Destroy;
readln;
end.
perl -e 'print for (map{chr(hex)}("4861707079204E6577205965617221"=~/(.{2})/g)), "\n";'