继上一个问题之后,当我尝试编译它时,我在这一行得到错误不兼容类型:
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.