Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.09.02;
Скачать: CL | DM;

Вниз

Incompatible types   Найти похожие ветки 

 
TBeginner   (2002-08-22 16:28) [0]

unit Unit1;

interface

type

TStatus = (StatusOn, StatusOff, StatusUnknown);

TDriveInfo = packed record
Letter : String;
Status : TStatus;
end;

PInteger = ^Integer;
PDriveInfo = ^TDriveInfo;

TMyList = class
protected
FDelta, FCount, FCapacity: Integer;
FItems: array of Pointer;
function GetPointer(Index: Integer): Pointer;
function IndexOf(Item: Pointer): Integer;
procedure Add(Item: Pointer);
procedure Delete(Index: Integer);
procedure Remove(Item: Pointer);
procedure Clear;
procedure Pack;
public
constructor Create(Delta: Integer);
destructor Destroy; override;
end;

TIntList = class(TMyList)
private
function Get(Index: Integer) : Integer;
public
function IndexOf(Item: Integer): Integer; reintroduce; overload;
procedure Add(Item: Integer); reintroduce; overload;
procedure Remove(Item: Integer); reintroduce; overload;
property Items[Index : Integer]: Integer read Get;
end;

TDriveInfoList = class(TMyList)
private
function Get(Index: Integer) : TDriveInfo;
public
function IndexOf(Item: TDriveInfo): Integer; reintroduce; overload;
procedure Add(Item: TDriveInfo); reintroduce; overload;
procedure Remove(Item: TDriveInfo); reintroduce; overload;
property Items[Index : Integer]: TDriveInfo read Get;
end;

implementation

{ Описание TMyList я пропускаю - там ошибок не возникает}

{ TIntList class }

function TIntList.IndexOf(Item: Integer): Integer;
var
I: Integer;
ItemPointer: PInteger;
begin
Result := -1;
I := 0;
if FItems <> nil then
while (Result = -1) and (I <= FCount - 1) do
begin
ItemPointer := FItems[I];
if ItemPointer^ = Item then Result := I; { Здесь всё нормально }
Inc(I);
end;
end;

{. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .}

{ TDriveInfoList class }

function TDriveInfoList.IndexOf(Item: TDriveInfo): Integer;
var
I: Integer;
ItemPointer: PDriveInfo;
begin
Result := -1;
I := 0;
if FItems <> nil then
while (Result = -1) and (I <= FCount - 1) do
begin
ItemPointer := FItems[I];
if ItemPointer^ = Item then Result := I; { Здесь ошибка - Incompatible types }
Inc(I);
end;
end;

end.

Почему?


 
Skier ©   (2002-08-22 16:39) [1]

>TBeginner

Operator : =

Operand types :

simple, class, class reference, interface, string, packed string


 
andy_prokofiev ©   (2002-08-22 16:44) [2]

while (Result = -1) and (I <= FCount - 1) do
begin
if FItems[i] = Item then Result := I;
Inc(I);
end;



 
TBeginner   (2002-08-22 16:56) [3]

> Skier

Не понял (извините за тупость :-).

> andy_prokofiev

Так ведь FItems[i] - это Pointer, а Item - это TDriveInfo.


 
andy_prokofiev ©   (2002-08-22 16:58) [4]

Извините
while (Result = -1) and (I <= FCount - 1) do
begin
if TDriveInfo(FItems[i]) = Item then Result := I;
Inc(I);
end;



 
Skier ©   (2002-08-22 17:03) [5]

>TBeginner



type
TStatus = (StatusOn, StatusOff, StatusUnknown);
TDriveInfo = packed record
Letter : String;
Status : TStatus;
end;
var
AFirst : TDriveInfo;
ASecond : TDriveInfo;
begin
FillChar(AFirst, SizeOf(TDriveInfo), 0);
FillChar(ASecond, SizeOf(TDriveInfo), 0);
if AFirst = ASecond then begin
ShowMessage("Я сравнил записи и обманул Delphi !") end; //if
end;



Страницы: 1 вся ветка

Текущий архив: 2002.09.02;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.012 c
14-3602
Bboy
2002-08-07 15:19
2002.09.02
Очень нужна программа


1-3328
Денис М Радченко
2002-08-20 16:55
2002.09.02
Поиск по файлам


1-3426
lob
2002-08-20 14:57
2002.09.02
Заставка наподобе ФОТОШОПА


3-3287
battar
2002-08-12 21:05
2002.09.02
QReport


3-3266
Loco
2002-08-12 14:25
2002.09.02
Поиск