毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

delphi一个类中如何调用非该类的重名过程

更新时间:2013-2-17:  来源:毕业论文

delphi一个类中如何调用非该类的重名过程
procedure gg; begin  Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION); end; procedure Test.gg;   begin  Application.MessageBox('我操', '麻痹', MB_OK +     MB_ICONINFORMATION);   end;     procedure Test.KK; begin  gg; end;

我想让TEST.KK调用全局的静态过程 !要怎么写呢

type  Test2 = class(TObject)     class procedure gg;   end;   class procedure Test2.gg; begin  Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION); end;   procedure Test.gg; begin  Application.MessageBox('我操', '麻痹', MB_OK +     MB_ICONINFORMATION) end;   procedure Test.KK; begin  test2.gg; end;

在普通方法声明和实现前冠以class关键字
type 
Test2 = class(TObject)    
class procedure gg;  
end;  
class procedure Test2.gg;
begin 
Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION);
end;
........
Test2.gg;  //调用 

//如果不想用class过程,也可以给过程起个别名 type  TPGG = procedure(); end;   procedure gg; begin  Application.MessageBox('马迪 ', '晕死ua', MB_OK + MB_ICONINFORMATION); end;   var  pg:TPGG = gg;      procedure TForm1.gg; begin  Application.MessageBox('我操', '麻痹', MB_OK +     MB_ICONINFORMATION); end;   procedure TForm1.KK; begin  pg; end;     // 或者用类似名字空间的方式 unit Unit2; interfaceuses  Forms; procedure gg();   implementationprocedure gg(); begin  Application.MessageBox('sdfdsf','fdsfs'); //; end; end.   ....   unit Unit1; type test = class;   gg; end; uses unit_1; procedure test.gg; begin  Unit2.gg; // 显示给出Unit2 end;

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。