在线等待!!!
解决方案 »
- TXT/HTML 文本 加密和解密,100分。速度
- 有关图形的选择问题?(我在画板上画几个直线,当鼠标移动到上面时能过判别出这个直线的两个端点。
- 请教高手!可以从哪些方面提高WEB SERVICE 执行效率
- 怎么把声卡的输入现则的默认麦克改为wavoutmin(立体声混音)
- tchart中的 2维直线打印不出来,只能打印出插入的点point,请教高手
- 关于写SQL语句
- 我的程序都关闭了,可是为什么进程还存在,我用了多线程的?
- 寻找一本较好的分布式开发得书或源代码!
- 请问如何才能监视一个应用程序,知道它何时产生,何时关闭?
- 在 vss check out 下修改代码出错!
- 100分请教!谁用过SoftSentry这个软件?可以给程序加上共享限制的?
- 求教:关于精确打印问题。
同时你还能学习到xml data banding 的知识。
我现在有一个这样的例子,代码如下:
unit Unit1;interface
type
IName = Interface
['{849EF1E1-EF57-11D5-8CB2-99DA2E405E0A}']
Function GetName(i: integer): String;
function GetID: string;
end;
implementationend.类的实现在下面这个单元里面
unit Unit3;interface
uses unit1;
type TMyClass = class(TInterfacedObject, IName)
private
protected
Function GetName(i: integer): String;
function GetID: string;
public
constructor create;
Destructor Destroy; override;
end;
implementation{ TMyClass }constructor TMyClass.create;
begin
end;destructor TMyClass.Destroy;
begin
inherited;end;function TMyClass.GetID: string;
begin
result := 'This is GetID test';
end;function TMyClass.GetName(i: integer): String;
begin
case i of
0:
Result := 'This is a test of GetName(0)';
1:
Result := 'This is a test of GetName(1)';
end;end;end.我在调用时用的是下面的单元,代码如下:unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, unit1, StdCtrls, Unit3, Buttons;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
FIName: IName;
FMyClass : TMyClass;
protected
public
end;
var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
FMyClass := TMyClass.Create;
FIName := FMYClass;
caption := FIName.GetName(1);
end;
end.这样在Button1单击时便会在窗体的标题上显示返回值,可是这样的好处是什么呢,用类完全可以实现。