Witam.
Mam do napisania program liczący pola i obwody figur w którym mam użyć dziedziczenia klas. Jednak mam problem program dziedziczy jedynie zmienne a funkcji już nie.
Może to mały problem, ale niestety nie wiem jak go rozwiązać.
Oto kod
unit Unit2;
interface
type
TCzwor = class
a: integer;
b: integer;
c: integer;
d: integer;
function obwod: integer;
constructor create (aa:integer;bb:integer;cc:integer;dd:integer);
end;
type
TProst = class (TCzwor)
function pole: integer;
constructor create (aa:integer;bb:integer);
end;
type
TKwad = class (TProst)
constructor create (aa:integer);
end;
implementation
function TCzwor.obwod: integer;
begin
obwod:= a+b+c+d;
end;
constructor TCzwor.create (aa: integer; bb: integer; cc: integer; dd: integer);
begin
a:=aa;
b:=bb;
c:=cc;
d:=dd;
end;
function TProst.obwod: integer;
begin
obwod:= 2*a+2*b;
end;
function TProst.pole: integer;
begin
pole:= a*b;
end;
constructor TProst.create (aa:integer;bb:integer);
begin
a:= aa;
b:= bb;
c:= a;
d:= b;
end;
end.
dodanie znacznika <code class="delphi"> - furious programming