请帮我看看这段程序!(50分)

  • 主题发起人 主题发起人 pcc_mmz1
  • 开始时间 开始时间
P

pcc_mmz1

Unregistered / Unconfirmed
GUEST, unregistred user!
这是一个关于接口授权的例程:
unit delegateUnit;
interface
uses
Messages, SysUtils, Dialogs;
type
IInterface1 =interface
['{EDC4D560-42FC-11D6-B5AF-00802964730E}']
procedure do
it1;
end;
IInterface2 =interface
['{EDC4D561-42FC-11D6-B5AF-00802964730E}']
procedure do
It2;
end;
Tobject1=class(TInterfacedObject,IInterface1)
protected
procedure do
It1;
public (1)
end;
TCombinedObject =class(TInterfacedObject,IInterface1,IInterface2)
protected
FObj1 :IInterface1;
public
constructor Create;
destructor Destroy;override;
procedure do
It2;
property MyIntf :IInterface1 read Fobj1 implements IInterface1;
class procedure a(var pa:integer);
end;
implementation
{ TCombinedObject }
constructor TCombinedObject.Create;
begin
inherited Create;
self.FObj1 :=TObject1.Create;
(2)
end;

destructor TCombinedObject.Destroy;
begin
self.FObj1 :=nil;
inherited;
end;

procedure TCombinedObject.DoIt2;
begin
showmessage('Inside TCombinedObject.DoIt2');
end;
{ Tobject1 }
procedure Tobject1.DoIt1;
begin
showmessage('Inside Tobject1.DoIt1');
end;
end.
请问:
1。为什么在“(1)”这个位置不需要申明Tobject1的构造函数Create()?
2。为什么没有申明也没有实现Tobject1的构造函数却可以调用Tobject1.Create?
请各大虾指教。小弟先谢了

 

Similar threads

后退
顶部