Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.09.02;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.007 c
1-3346
Cr@sh
2002-08-21 20:08
2002.09.02
Изменение картинки в b:TBitmap.


1-3516
TBeginner
2002-08-21 14:20
2002.09.02
Class


1-3467
vitnt2000
2002-08-20 07:21
2002.09.02
Как программно заставить выпасть DateTimePicker?


1-3409
peter_login
2002-08-22 13:26
2002.09.02
Генерация скрипта VB


1-3458
Дельфятник
2002-08-20 11:28
2002.09.02
Рисование на TRadioGroup через его Handle.





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский