各位高手,本人刚刚学delphi,一个问题!你们肯定会!请说明一下!

epoluodi 2003-06-17 05:53:08
of object
这个在过程后,有什么意义!我不太明白
...全文
29 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jorge 2003-06-20
  • 打赏
  • 举报
回复
方法指针,是函数指针的一种.引用一个对象的方法而不是独立的函数的时候,必须用of object的函数指针.
对象的方法和独立函数的区别在于一个隐含参数,好像是,类的方法有个隐含的参数,传递主调此方法的对象.比如 AnObject.AMethod(AParam) ,编译时是按 AMethod(AnObject,AParam) 处理的.而独立方法没有这个隐含参数,归根到底还是函数指针和其引用的函数参数一致的问题.
zlyanyan 2003-06-20
  • 打赏
  • 举报
回复
procedure .... of object 是方法指针
来看方法的定义
TMethod = record
Code, Data: Pointer;
end;
它包含Code:代码指针,Data:数据指针,其实Code指向函数体本身,Data指向所属的类

这样不同的类可以调用统一个方法,但Data指向的类不同,Code执行效果也不同-对不同的
类操作,例如“事件”Event就是这样做的
mbzdh 2003-06-19
  • 打赏
  • 举报
回复
表明是什么类!在这里表明自定义类型proc为一个object类的过程!!!!!!!!!!!!
sztony 2003-06-19
  • 打赏
  • 举报
回复
方法指针
ronaldli 2003-06-18
  • 打赏
  • 举报
回复
用来定义事件过程的类型
如果你开发自己的控件中,事件的参数需要自己定义,那么定义时就要加上of object,如

TMyNodify = procedure (Sender: TObject; ARef1: Integer; ARef2: TControl) of object;

type
MyComponent = class(TComponent)
...
private
...
FMyEvent: TMyNodify;
...
published
...
property OnMyEvent: TMyNodify read FMyEvent write FMyEvent;
...
end;
microjuz 2003-06-17
  • 打赏
  • 举报
回复
If you want to reference a method of an instance object (see Classes and objects), you need to add the words of object to the procedural type name. For example

type

TMethod = procedure of object;
TNotifyEvent = procedure(Sender: TObject) of object;

These types represent method pointers. A method pointer is really a pair of pointers; the first stores the address of a method, and the second stores a reference to the object the method belongs to. Given the declarations

type

TNotifyEvent = procedure(Sender: TObject) of object;
TMainForm = class(TForm)
procedure ButtonClick(Sender: TObject);
...
end;
var
MainForm: TMainForm;
OnClick: TNotifyEvent

we could make the following assignment.

OnClick := MainForm.ButtonClick;

Two procedural types are compatible if they have

the same calling convention,
the same return value (or no return value), and
the same number of parameters, with identically typed parameters in corresponding positions. (Parameter names do not matter.)

Procedure pointer types are always incompatible with method pointer types. The value nil can be assigned to any procedural type.
Nested procedures and functions (routines declared within other routines) cannot be used as procedural values, nor can predefined procedures and functions. If you want to use a predefined routine like Length as a procedural value, write a wrapper for it:

function FLength(S: string): Integer;

begin
Result := Length(S);
end;
wooden954 2003-06-17
  • 打赏
  • 举报
回复
表明是什么类!在这里表明自定义类型proc为一个object类
epoluodi 2003-06-17
  • 打赏
  • 举报
回复
这里面怎么多高手,为什么不能帮助一下啊!
type
proc = wndproc(value:integer) of object
of object 这个有什么意义!
我不明白啊
dudunono 2003-06-17
  • 打赏
  • 举报
回复
不太明白
JackyChang 2003-06-17
  • 打赏
  • 举报
回复
guanzhu!

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧