Tipcom = class
fIpList: TStrings;
private
property Iplist: TStrings read fIplist write fIplist;
public
constructor Create(ipstrs:Tstrings);
destructor Destroy; override;
function TwoIpthan(oneip, twoip: string): integer;
//one>two return 1, else 0;
function Iplistcom(Ips: TStrings): TStrings;
end;//创建
constructor TIpcom.Create(ipstrs:Tstrings);
begin
inherited Create;
Iplist:=ipstrs;
end;
procedure TFrmChinaIp.BitBindexClick(Sender: TObject);
var
i: integer;
tmpstr, sqlstr: string;
ips: Tipcom;
begin
ips:=Tipcom.Create(memo1.lines); //这里运行时候一建立就game over.
fIpList: TStrings;
private
property Iplist: TStrings read fIplist write fIplist;
public
constructor Create(ipstrs:Tstrings);
destructor Destroy; override;
function TwoIpthan(oneip, twoip: string): integer;
//one>two return 1, else 0;
function Iplistcom(Ips: TStrings): TStrings;
end;//创建
constructor TIpcom.Create(ipstrs:Tstrings);
begin
inherited Create;
Iplist:=ipstrs;
end;
procedure TFrmChinaIp.BitBindexClick(Sender: TObject);
var
i: integer;
tmpstr, sqlstr: string;
ips: Tipcom;
begin
ips:=Tipcom.Create(memo1.lines); //这里运行时候一建立就game over.
constructor TIpcom.Create(ipstrs:Tstrings);
begin
inherited Create;
Iplist:=ipstrs;//这里改改
end;
fIpList: TStringList;// 修改
published
property Iplist: TStrings read fIplist write fIplist;
fIpList: TStringList;// 修改
fIpList: TStringList;// 修改TString 是一个虚类,是不能够直接使用的。
这个东西的错误很容易找,自己调试一下就知道了!这种问题不需要问吧
fIpList: TStringList;//创建
constructor TIpcom.Create(ipstrs:Tstrings);
begin
inherited Create;
fIpList:= TStringList.Create;
Iplist.Assign(ipstrs);
end;
兄弟你知道什么是oo吗,还是多看看书吧
什么Delphi有个毛病TStrings是抽象类,不能用来构造实例,要通过子类来构造如TStringList等,delphi在语法上允许构造抽象类的,但是这是不通语义的,在运行时会提示错误的。
var
a:TStrings;
begin
a:=TStringList.create;
...
end;
改成TStringList好处理些,呵:
fIpList: TStringList;你上面的做法仅仅时为了解决的当前的问题,如果,你把他改了,你就破坏作者原有的实现多态的初衷了,肯定在扩展上会出现问题
如:memo1.lines:=Iplistcom(memo1.lines);
这是啥(Iplistcom?)
Iplistcom的原形:
function Iplistcom(Ips: TStrings): TStrings; //用来ip地址排序。
memo1.lines:=Iplistcom(memo1.lines)
您所说的类中没有create!需要外界create?