[fpc-pascal]Interfaces, What am I doing wrong?
Jon Sawyer
bq at badquanta.net
Mon May 12 05:01:36 CEST 2003
I'm trying to learn how to use Interfaces. I'm going by Delphi's
documentation. I know that I'm ignoring GUIDs but as far as I can tell from
the docs there not vital. If there are how can I generate my own?? ^_^
But I'm getting real stuck. The doc's on Delphi's web page mentions NOTHING
about implementing IUnknown's methods. Do I have to?
Thanks for the help. ^_^
The code at the bottom generates the following compiler messages:
########## CONSOLE OUTPUT ############
bash-2.05b$ ppc386 qbase.pp
Free Pascal Compiler version 1.1 [2003/05/10] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling qbase.pp
qbase.pp(14,7) Error: No matching implementation for interface method
"IUnknown.QueryInterface(const TGuid,out <Formal type>):LongInt" found
qbase.pp(14,7) Error: No matching implementation for interface method
"IUnknown._AddRef:LongInt" found
qbase.pp(14,7) Error: No matching implementation for interface method
"IUnknown._Release:LongInt" found
qbase.pp(28,1) Fatal: There were 3 errors compiling module, stopping
bash-2.05b$
########### END OF CONSOLE OUTPUT ###########
########### SOURCE CODE #####################
{$Mode ObjFPC}
Unit QBase;
Interface
Type
iQObject
= Interface
Procedure SetName(iName: String);
Function GetName: String;
Property Name : String;
end;
tQObject
= Class (iQObject)
Protected
fName : String;
Public
Constructor Create;
Destructor Destroy; Override;
Procedure SetName(iName: String);
Function GetName: String;
Property Name : String
Read GetName
Write SetName;
end;
Implementation
Constructor tQObject.Create;
Begin
fName := 'tQObject';
end;
Destructor tQObject.Destroy;
Begin
end;
Procedure tQObject.SetName(iName: String);
Begin
Writeln('Renaming ', fName,' to ', iName);
fName := iName;
end;
Function tQObject.GetName: String;
Begin
Result := fName;
end;
end.
More information about the fpc-pascal
mailing list