0
繼previous question索引屬性的聲明,當我嘗試編譯此我得到這一行的錯誤不兼容的類型:E2008不兼容的類型在德爾福
Property player[i : integer] : TStringList read p;
我不確定爲什麼?這是全班同學:
unit Battle;
interface
uses
SysUtils,Dialogs,Classes,inifiles, StdCtrls;
type
TPlayers = class
Private
p : array[1..20] of TStringList;
FPlaceUnit: Boolean;
FTeamCount: Integer;
Public
Property player[i : integer] : TStringList read p;
property PlaceUnit : Boolean read FPlaceUnit write FPlaceUnit;
procedure AddPlayer (PlayerNo : integer; player : String);
property TeamCount : Integer read FTeamCount write FTeamCount;
constructor Create; virtual;
End;
{Host class}
THostPlayers = Class(TPlayers)
Private
FIsHost: string;
Public
constructor Create; override;
property IsHost : string read FIsHost write FIsHost;
End;
{Guest Class}
TGuestPlayers = Class(TPlayers)
Private
FIsGuest: string;
Public
constructor Create; override;
property IsGuest : string read FIsGuest write FIsGuest;
End;
implementation
uses
main;
{constructor}
constructor TPlayers.Create;
begin
p := TStringList.Create;
end;
constructor THostPlayers.Create;
begin
inherited; // Calls TPlayers.Create
IsHost := 'No';
PlaceUnit := true;
TeamCount :=0;
end;
constructor TGuestPlayers.Create;
begin
inherited; // Calls TPlayers.Create
IsGuest := 'No';
PlaceUnit := true;
TeamCount := 0;
end;
{ADD Player}
procedure TPlayers.AddPlayer(PlayerNo : integer; player : String);
var
CharINI : TIniFile;
begin
CharINI := Tinifile.Create(thisdir+'\char\charstats.ini');
CharINI.ReadSectionValues(player,player[PlayerNo]);
CharINI.Free;
end;
end.
ok我試過這個,但現在我得到錯誤,預計錯誤;但得到:後第二:在「getplayer(我:整數):tstringlist;」 –
ahh納米,它的功能,而不是過程..:D –
這是一種重複。請不要將每天發生的每個語法錯誤都發布爲一個新問題Glen。 :-) –