property在interface中的定义问题 (50分)

M

mywyn

Unregistered / Unconfirmed
GUEST, unregistred user!
Itest=interface
property Bs:string read,write;
end;

上面的语句肯定是通不过的。我想实现的效果是:实现类可以定义成:
property Bs:string read FBs write FBs(用变量) 或
property Bs:string read GetFBs write SetFBs(用函数)
但是我的接口又不能定义成:
Itest=interface
function GetFBs:string;
procedure SetFBs(const value:string);
property Bs:string read GetFbs write SetFBs;
end;
这样会强迫实现类一定要用函数实现。
我不知这样接口定义该怎么写。C#中可以这样写 string Bs {get;set;}


 
在delphi里面属性是可以重定义的
也就说在接口里可以定义
property Bs:string read GetFbs write SetFBs;
在继承接口的类里定义成
property Bs:string read FBs write FBs
应该没什么问题。
 
接口不允许变量啊:(
听课~
 
在Delphi的接口中只能通过函数和过程来处理属性
 
to loco:
不行啊!!!
 
property Property1: PWideChar read Get_Property1 write Set_Property1;
function Get_Property1: PWideChar;
safecall;
procedure Set_Property1(Value: PWideChar);
safecall;
 
to dcsdcs:
不知老兄是什么意思???
 
可以象这样,但是string是delphi的自己格式,他自己进行维护其空间,
所以必须采用其他的变量,比如:PWideChar,pchar等
Itest=interface
function GetFBs:pWideChar;
procedure SetFBs(value:pWideChar);
property Bs:pWideChar read GetFbs write SetFBs;
end;
 
to dcsdcs:
可能是你没有仔细看我的问题,我的焦点是怎样在不定义function或procedure的情况下,
在interface中定义property。不过,还是要谢谢你!!!
 
为什么发了一文章(青年报上的),账号封了就不开放?妈的!有这么严重吗?
 
只能那样吧?
 
to Yukin:
Yes
 
delphi与Java,C#类型的编程语言实现机制是不一样的,接口属性不用函数无法实现
Delphi的函数多得除了lisp以外可以排第2了
 
多人接受答案了。
 
顶部