在类内部传递实例参数

dqlihb 2009-11-13 07:44:21

tmyclass=class
private
public
procedure proc(i:integer;myclass1:tmyclass);
end;

procedure tmyclass.proc(i:integer;myclass1:tmyclass);
begin
func(i,aaa);
end;

上面的代码需要在类内部传递实例参数
请问上面的代码可以么
如果可以,实例本身用什么来表示呢(也就是代码中的aaa换成什么呢)
...全文
58 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dqlihb 2009-11-13
  • 打赏
  • 举报
回复
要在内部自动判断实例
sunnauq 2009-11-13
  • 打赏
  • 举报
回复
顶一个
mjp1234airen4385 2009-11-13
  • 打赏
  • 举报
回复
1楼应该是楼主想的东西吧。
dqlihb 2009-11-13
  • 打赏
  • 举报
回复
普京在吗?
wooden954 2009-11-13
  • 打赏
  • 举报
回复
顶一个
dqlihb 2009-11-13
  • 打赏
  • 举报
回复
function TMyClass.aaa: boolean;
type mypointer = function(i: integer; xxx: TMyClass): boolean; stdcall;
var
XHandle: Thandle;
frm_p: mypointer;
i: integer;
begin
result := false;
XHandle := loadlibrary('DllA.dll');
if XHandle > 32 then
try
frm_p := GetProcAddress(XHandle, 'Func');
result := frm_p(0, xxx); /// 此处类型错误 xxx extended
finally
freelibrary(XHandle);
end;
end;
npkaida 2009-11-13
  • 打赏
  • 举报
回复

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
tmyclass=class
private
k: integer;
public
procedure proc(i:integer;myclass1:tmyclass);
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
c:tmyclass;
begin
c:=tmyclass.Create;
try
c.k:=100;
c.proc(1, c);
finally
c.Free;
end;
end;

{ tmyclass }

procedure tmyclass.proc(i: integer; myclass1: tmyclass);
begin
ShowMessage(inttostr(i)+#13#10+inttostr(Myclass1.k));
end;

end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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