我
我就是一个问题
Unregistered / Unconfirmed
GUEST, unregistred user!
Var
insertflag, eraseflag: integer;
pointTIOPOINT;
Begin
eraseflag := 1;
insertflag := 1;
new(point);
Case (pID) Of //根据元件的不同来选择画什么元件
1: Begin
point^:=LD.Create;
point^.setflag(1);
point^.setcode('LD');
End;
2: Begin
point^ := LDI.Create;
point^.setflag(2);
point^.setcode('LDI');
End;
Type
LD = Class(TIOPOINT)
Private
{ Private declarations }
Public
{ Public declarations }
Procedure IOPOINT(x, y, flg: integer; cd, nm, ad: String); Overload;
Procedure IOPOINT(); Overload;
Procedure put_img(x, y: integer; MCanvas: TCanvas);
Procedure print(x, y: integer; MCanvas: TCanvas);
End;
Type
PTIOPOINT = ^TIOPOINT;
TIOPOINT = Class(TObject)
Private
{ Private declarations }
Protected
name: String;
code: String;
addr: String;
xpoint, ypoint: integer;
flag: integer;
fiveflag: integer;
visit: Boolean;
right: PTIOPOINT;
down: PTIOPOINT;
left: PTIOPOINT;
up: PTIOPOINT;
unup: PTIOPOINT;
undown: PTIOPOINT;
Public
{ Public declarations }
Procedure IOPOINT(x, y, fl: integer; cd, nm, ad: String); Overload;
Procedure IOPOINT(); Overload;
Procedure setname(ioname: String);
Procedure setaddr(ioaddr: String);
Procedure setcode(iocode: String);
Procedure setflag(flg: integer);
Procedure setfiveflag(fivflg: integer);
Procedure setvisit(x: Boolean);
Procedure setwhere(x, y: integer);
Procedure getname(result_name: String);
Procedure getaddr(result_addr: String);
Procedure getcode(result_code: String);
Function getflag(): integer;
Function getfiveflag(): integer;
Function getxpoint(): integer;
Function getypoint(): integer;
Procedure changeimg(x, y: integer; MCanvas: TCanvas);
Procedure setstatu(); Virtual;
Procedure print(x, y: integer; MCanvas: TCanvas); Virtual;
Procedure put_img(x, y: integer; MCanvas: TCanvas); Virtual;
Function testaddr(): integer; Virtual;
End;
我以为经过上面的语句之后point指针里面应该保存LD的类指针,但是并没有像我想的那样依然是基类TIOPOINT的指针.因为不同的类LD,LDI的具体执行函数是不同的.各位谁能帮忙一下!
insertflag, eraseflag: integer;
pointTIOPOINT;
Begin
eraseflag := 1;
insertflag := 1;
new(point);
Case (pID) Of //根据元件的不同来选择画什么元件
1: Begin
point^:=LD.Create;
point^.setflag(1);
point^.setcode('LD');
End;
2: Begin
point^ := LDI.Create;
point^.setflag(2);
point^.setcode('LDI');
End;
Type
LD = Class(TIOPOINT)
Private
{ Private declarations }
Public
{ Public declarations }
Procedure IOPOINT(x, y, flg: integer; cd, nm, ad: String); Overload;
Procedure IOPOINT(); Overload;
Procedure put_img(x, y: integer; MCanvas: TCanvas);
Procedure print(x, y: integer; MCanvas: TCanvas);
End;
Type
PTIOPOINT = ^TIOPOINT;
TIOPOINT = Class(TObject)
Private
{ Private declarations }
Protected
name: String;
code: String;
addr: String;
xpoint, ypoint: integer;
flag: integer;
fiveflag: integer;
visit: Boolean;
right: PTIOPOINT;
down: PTIOPOINT;
left: PTIOPOINT;
up: PTIOPOINT;
unup: PTIOPOINT;
undown: PTIOPOINT;
Public
{ Public declarations }
Procedure IOPOINT(x, y, fl: integer; cd, nm, ad: String); Overload;
Procedure IOPOINT(); Overload;
Procedure setname(ioname: String);
Procedure setaddr(ioaddr: String);
Procedure setcode(iocode: String);
Procedure setflag(flg: integer);
Procedure setfiveflag(fivflg: integer);
Procedure setvisit(x: Boolean);
Procedure setwhere(x, y: integer);
Procedure getname(result_name: String);
Procedure getaddr(result_addr: String);
Procedure getcode(result_code: String);
Function getflag(): integer;
Function getfiveflag(): integer;
Function getxpoint(): integer;
Function getypoint(): integer;
Procedure changeimg(x, y: integer; MCanvas: TCanvas);
Procedure setstatu(); Virtual;
Procedure print(x, y: integer; MCanvas: TCanvas); Virtual;
Procedure put_img(x, y: integer; MCanvas: TCanvas); Virtual;
Function testaddr(): integer; Virtual;
End;
我以为经过上面的语句之后point指针里面应该保存LD的类指针,但是并没有像我想的那样依然是基类TIOPOINT的指针.因为不同的类LD,LDI的具体执行函数是不同的.各位谁能帮忙一下!