M
morsh
Unregistered / Unconfirmed
GUEST, unregistred user!
定义了一个类,当在buttonclick事件中输入“ttiger.”的时候出现错误提示:''Unable to invoke Code Completion due to errors in source code''代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
tanimal=class
protected
fname:string;
fsort:string;
public
property name:string read fname write fname;
property sort:string read fsort write fsort;
constructor create;virtual;
function feed:string;virtual;
end;
ttiger=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
tcamel=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
tpeafowl=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ani:tanimal;
implementation
{$R *.dfm}
constructor tanimal.create;
begin
fname:='老虎';
fsort:='肉食类动物';
end;
function tanimal.feed:string;
begin
result:='肉类';
end;
constructor tcamel.create;
begin
fname:='骆驼';
fsort:='草食类动物';
end;
function tcamel.feed:string;
begin
result:='草';
end;
constructor tpeafowl.create;
begin
fname:='孔雀';
fsort:='禽类';
end;
function tcamel.feed:string;
begin
result:='粮食';
end;
constructor ttiger.create;
begin
fname:='老虎';
fsort:='肉食类动物';
end;
function ttiger.feed:string;
begin
result:='肉类';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
[red]ani:=ttiger.[/red]
end;
end.
刚学dephi,请各位高手指点一下。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
tanimal=class
protected
fname:string;
fsort:string;
public
property name:string read fname write fname;
property sort:string read fsort write fsort;
constructor create;virtual;
function feed:string;virtual;
end;
ttiger=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
tcamel=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
tpeafowl=class(tanimal)
public
constructor create;override;
function feed:string;override;
end;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ani:tanimal;
implementation
{$R *.dfm}
constructor tanimal.create;
begin
fname:='老虎';
fsort:='肉食类动物';
end;
function tanimal.feed:string;
begin
result:='肉类';
end;
constructor tcamel.create;
begin
fname:='骆驼';
fsort:='草食类动物';
end;
function tcamel.feed:string;
begin
result:='草';
end;
constructor tpeafowl.create;
begin
fname:='孔雀';
fsort:='禽类';
end;
function tcamel.feed:string;
begin
result:='粮食';
end;
constructor ttiger.create;
begin
fname:='老虎';
fsort:='肉食类动物';
end;
function ttiger.feed:string;
begin
result:='肉类';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
[red]ani:=ttiger.[/red]
end;
end.
刚学dephi,请各位高手指点一下。