关于属性的继承,请大家来帮忙! ( 积分: 100 )

  • 主题发起人 主题发起人 yzykjh
  • 开始时间 开始时间
Y

yzykjh

Unregistered / Unconfirmed
GUEST, unregistred user!
TAA = class(TComponent)
private
procedure SetPurview(Value: boolean);
published
property Purview: boolean read fPurview write SetPurview;
end;

TBB = class(TAA)
private
procedure SetPurview(Value: boolean);
published
property Purview: boolean read fPurview write SetPurview;
//请问TBB怎样才能执行TAA类的Purview,又执行TBB的Purview;
//也就是TBB继承TAA的Purview属性,同时也要执行自己Purview的代码内容。
end;
 
TAA = class(TComponent)
private
procedure SetPurview(Value: boolean);
published
property Purview: boolean read fPurview write SetPurview;
end;

TBB = class(TAA)
private
procedure SetPurview(Value: boolean);
published
property Purview: boolean read fPurview write SetPurview;
//请问TBB怎样才能执行TAA类的Purview,又执行TBB的Purview;
//也就是TBB继承TAA的Purview属性,同时也要执行自己Purview的代码内容。
end;
 
TAA = class(TComponent)
private
procedure SetPurview(Value: boolean); [red]virtual;[/red]
published
property Purview: boolean read fPurview write SetPurview;
end;

TBB = class(TAA)
private
procedure SetPurview(Value: boolean); [red]override;[/red]
published
property Purview: boolean read fPurview write SetPurview;
end;
 
To: Corn3
TBB提示SetPurview没有找到基类。你试了吗?
 
procedure TBB.setPurview(value: boolean);
begin
Showmessage('TBB類SetPurview');
inherited;//加上this code

end;
 
TAA = class(TComponent)
private
published
procedure SetPurview(Value: boolean); virtual;
property Purview: boolean read fPurview write SetPurview;
end;

TBB = class(TAA)
private
procedure SetPurview(Value: boolean); override;
published
// property Purview: boolean read fPurview write SetPurview;
end;
 
这样做有什么用吗?
 

Similar threads

I
回复
0
查看
649
import
I
I
回复
0
查看
744
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
507
import
I
后退
顶部