{$N+} uses crt; type PT = ^T; T = object constructor create; destructor done; end; PTint = ^Tint; Tint = object(T) value: integer; procedure init(X: integer); procedure print; end; PTfloat = ^Tfloat; Tfloat = object(T) value: double; procedure init(X: double); procedure print; end; constructor T.create; begin end; destructor T.done; begin end; procedure Tint.init(X: integer); begin value := X end; procedure Tint.print; begin write(value:4) end; procedure Tfloat.init(X: double); begin value := X; end; procedure Tfloat.print; begin write(value:8:4) end; const maxSize = 100; type TArr = object arr: array[1 .. maxSize] of PT; num:byte; constructor init; function set_index(i: integer; const p: PT):boolean; procedure count_each(const p: PT); end; constructor TArr.init; var i:byte; begin for i:=1 to maxSize do arr[i]:=nil; end; function TArr.set_index(i: integer; const p: PT):boolean; begin if i<= maxSize then if arr[i]=nil then begin arr[i]:=p; set_index:=true; end else set_index:=false; end; procedure TArr.count_each(const p: PT); var i, count: integer; begin count := 0; for i := 1 to maxSize do if (arr[i]<>nil) and (typeof(arr[i]^) = typeof(p^)) then inc(count); writeln('count = ', count); dispose(p,done); end; var obj_int: PTint; obj_float:PTfloat; any_arr: TArr; mem:longint; begin clrscr; mem:=memavail; any_arr.init; obj_int := new(PTint,create); obj_int^.value := 3; any_arr.set_index(1, obj_int); obj_float := new(PTfloat,create); obj_float^.value := 3.5; if any_arr.set_index(1, obj_float)=false then begin writeln('Error'); readln; end; any_arr.count_each(new(PTfloat,create)); dispose(obj_float,done); dispose(obj_int,done); writeln('Difference : ',mem-memavail); readln; end.