Главная страница
    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.011 c
7-3645
Alexander
2002-06-21 02:28
2002.09.02
Как мне применить темы Windows XP в окне, которое создано в файле


1-3474
dimanew
2002-08-21 06:19
2002.09.02
Как в MessageDlg вместо Yes, No сделать Да, Нет?


6-3547
dd
2002-06-21 13:59
2002.09.02
RunTime and WebBrowser


4-3663
SeB
2002-06-20 10:59
2002.09.02
Блокировка машины в Windows и неубиваемая программа


14-3596
Sergo
2002-08-07 10:48
2002.09.02
Окно





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский