有如下的简单对象层次结构
TLiveThing=class
protected
FTest:string;
constructor Create(whereLive:string);overload;virtual;
constructor Create(haveBone:Boolean);overload;virtual;
end;
THuman=class(TLiveThing)
public
constructor Create(whereLive:string);overload;override;
constructor Create(age:integer);overload;
end;
Run Code Online (Sandbox Code Playgroud)
在理论上,如果我实例化THuman,我有2个构造函数,但实际上我有5个构造函数通过代码洞察显示,实际上我想看到3个构造函数, - Create(whereLive:String),overriden - Create(age:integer) - 创建(haveBone:整数)
human:=THuman.Create( <=====in there I have 5 suggestion constructor
Run Code Online (Sandbox Code Playgroud)
为什么我有这种奇怪的行为?如何解决它,因为它太烦人了,我总是检查我的类,我需要实例化,如果我实例化如下
human:=THuman.Create(); <===== it doesnt give me error
Run Code Online (Sandbox Code Playgroud)
我如何完全隐藏我的anchestor构造函数?,因为如果我像上面那样实例化,完全给我一个错误的对象
更新:我也可以在TObject中看到默认的Create参数
我有这样的示例代码
IExample=interface
procedure Test;
end;
TBaseClass=class
function Check:boolean;abstract;
end;
TExampleObject=class(TInterfacedObject,IExample)
end;
TAnotherObject=class(TBaseClass)
end;
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何从祖先实现接口方法和抽象方法?
我使用Visual Studio和C#,从抽象方法和接口方法实现起来非常简单,我只需右键单击我的类和实现方法.
RAD Studio XE2是否具有相同功能的类似工具或第三方工具?因为我必须手动记下所有的抽象和接口方法,这很烦人
我是delphi XE2的新手,我想知道一些事情,如果我喜欢这个代码
TSomeClass=class
strict private
class var
FCounter:integer;
public
class procedure SomeProcedure();static
end;
implementation
class procedure SomeProcedure()
begin
inc(FCounter);
end;
initialization
begin
FCounter:=0;
end;
finalization
begin
FCounter:=0;
end;
Run Code Online (Sandbox Code Playgroud)
根据我的理解,SomeProcedure()将在内存和单个实例上静态,
我的问题
delphi ×3
methods ×3
abstract ×1
class ×1
interface ×1
overloading ×1
overriding ×1
static ×1
virtual ×1