Okay here is my second bit of confusion cleared up regarding interface
inheritance.
If I declare the following types
Type
INoiseable = interface
['{B7A2C437-EC4C-485D-B7E2-CD085E8414BE}']
procedure MakeNoise;
end;
ISpeakable = interface(INoiseable)
['{E789E48D-4105-4181-B644-96B94F27E48A}']
procedure Speak;
end;
TPerson = class(TInterfacedObject, ISpeakable)
procedure MakeNoise;
procedure Speak;
end;
procedure TPerson.MakeNoise;
begin
showMessage('Some Noise');
end;
procedure TPerson.Speak;
begin
ShowMessage('Some Speach')
end;
procedure TForm4.Button1Click(Sender: TObject);
var
Person : TPerson;
Speakable : ISpeakable;
begin
Speakable := TPerson.Create;
(Speakable as INoiseable).MakeNoise; //this fails - TPerson does not
support INoiseable - eventhough it inherits from ISpeakable
(Speakable as ISpeakable).MakeNoise; //this is fine
end;
However if I change my TPerson to the following
TPerson = class(TInterfacedObject, ISpeakable, INoiseable)
then all is happy. I don't quite understand fully why as yet - I guess
you can't get an interface pointer to an object unless it explicitly
states that it supports that interface.
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
Alister Christie wrote:
No,
There is some other stuff that is confusing me also to do with interface
inheritance - I think I'm going to have to do some reading.
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
Todd Martin wrote:
Hi Alister
Are you implementing IXMLResidentialType via delegation?
Todd.
I'm having some fun with interfaces
I have two interfaces IXMLResidentialType and IAuctionable.
I have a class which implements these two interfaces
TXMLResidentialType = class(TXMLNode, IXMLResidentialType, IAuctionable)
...
I have some code
var
Res : IXMLResidentialType;
Auctionable : IAuctionable;
begin
...
if Res.QueryInterface(IAuctionable, Auctionable) = 0 then
ShowMessage('Auctionable');
What I'm trying to determine is if Res implements IAuctionable - which
it does (through TXMLResidentialType which effective Res is an instance
of), however IXMLResidentialType doesn't seem to realise this. How do I
make this work?
Does this question make any sense?
If I'm not able to do this it's not too much of a problem, but will mean
a bunch of duplicated code.
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe