unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure Amethod(f:integer);overload;
procedure Amethod(f1:string);overload;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Amethod(f:integer);
begin
//
end;procedure TForm1.Amethod(f1:string);
begin
//
end;end.
-----------------------------
我这样声明重载的过程Amethod,有错误,但我讲过程声明部分放入private或者public部分就能通过了.........
这是问题一..........
问题二,,将测试的重载函数放到一个新建的Unit中,重载函数的声明却放在上面的任意部分却不会提示出错....
我想问为什么?
---------------最后想问下,不放到protect和public声明的函数或过程与放在里面声明的有什么区别------------
求解迷惑............
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure Amethod(f:integer);overload;
procedure Amethod(f1:string);overload;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Amethod(f:integer);
begin
//
end;procedure TForm1.Amethod(f1:string);
begin
//
end;end.
-----------------------------
我这样声明重载的过程Amethod,有错误,但我讲过程声明部分放入private或者public部分就能通过了.........
这是问题一..........
问题二,,将测试的重载函数放到一个新建的Unit中,重载函数的声明却放在上面的任意部分却不会提示出错....
我想问为什么?
---------------最后想问下,不放到protect和public声明的函数或过程与放在里面声明的有什么区别------------
求解迷惑............
解决方案 »
- 推荐关于DELPHI的两篇文章: 有兴趣的朋友来看一下.
- 如何隐藏任务栏上的图标啊 求救
- 有谁熟悉 TXMLDocment 控件?
- 求救:怎么无法创建MDI窗体?
- 怎样通过delphi程序给win2000 or xp添加用户?
- 如何获得请求中的html文本的内容
- 请高高手赐教:如何对耳麦进行录音
- AnimateWindow动画功能,为什么只有在第一次创建窗口时起作用,对于非模态窗口,在执行show命令时为什么不起作用?
- 两个关于onkeypress事件的问题,参与者有分
- ---------------help me about Session.GetDatabaseName
- 哪有delphi写的三层酒店管理系统的源代码(C/S模式)下载?
- tlistview控件小问题,高手进在线等之
前两个问题,搞不清楚。
期待高手回答。
AClass = Class
//此处默认是published
public
//公开的
private
//私有的
protect
//保护的
published
//发行的
end;
procedure TForm1.Amethod(f1:string);
begin
//
end;
还有就是请您再测试一遍,我是在一个运行没有错误的程序里添加一个Unit单元,然后把要测试的重载函数放在Unit单元并改动他们声明的位置.....经过测试程序没有爆错啊!
请求解答这个问题........
对了我怎么在自己买的书本上看不到你写的这些,我看的书本上没有写default是属于什么可见度。听你这么说default区域还要针对什么类型才属于什么可见度。有的属于public,有的属于published等等,
能不能告诉我哪本书将delphi剖析的比较清楚的
Only one member of a set of overloaded functions may be published because the RTTI generated for procedures only contains the name.In the example shown here, both overloaded p1 functions are contained in a published section, which is not allowed.Further, since the $M+ state is used, the Extended class starts with published visibility, thus the error will also appear for this class also.再看源代码:
{$M+} TPersistent = class(TObject)
private
procedure AssignError(Source: TPersistent);
protected
procedure AssignTo(Dest: TPersistent); virtual;
procedure DefineProperties(Filer: TFiler); virtual;
function GetOwner: TPersistent; dynamic;
public
destructor Destroy; override;
procedure Assign(Source: TPersistent); virtual;
function GetNamePath: string; dynamic;
end;{$M-}
所以从TPersistent开始,其子类都是默认为published可见。
而published可见的方法需要在RTTI记录方法名,所以不支持重载,如果方法重载了,用方法名就无法定位到具体方法了。