emu10k1
asked on
interface at different units
Hi, I create a unit and put this code there:
unit Unit2;
interface
implementation
// the interface code
type
IAgendas = interface
['{2CFE9F89-A88D-4179-9429 -2340CC674 35B}']
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
end;
end.
-------------------------- --------
now I create another unit to use the interface
unit Unit3;
interface
uses Unit2; // to use the interface declared at unit2
implementation
type
TAgenda = class (TInterfacedObject, IAgendas)
public
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
private
Nome: String;
Fone: String;
end;
function TAgenda.getNome(): String;
begin
Result := Self.Nome;
end;
procedure TAgenda.setNome(Nome: String);
begin
Self.Nome := Nome;
end;
function TAgenda.getFone(): String;
begin
Result := Self.Fone;
end;
procedure TAgenda.setFone(Fone: String);
begin
Self.Fone := Fone;
end;
end.
but it shows an error when I try to compile at Unit3: 'Undeclared identifier: 'IAgendas'
Why it shows me that error? I put the Unit at uses clause and it didn't recognize IAgendas.
Please help me with that, Thanks.
unit Unit2;
interface
implementation
// the interface code
type
IAgendas = interface
['{2CFE9F89-A88D-4179-9429
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
end;
end.
--------------------------
now I create another unit to use the interface
unit Unit3;
interface
uses Unit2; // to use the interface declared at unit2
implementation
type
TAgenda = class (TInterfacedObject, IAgendas)
public
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
private
Nome: String;
Fone: String;
end;
function TAgenda.getNome(): String;
begin
Result := Self.Nome;
end;
procedure TAgenda.setNome(Nome: String);
begin
Self.Nome := Nome;
end;
function TAgenda.getFone(): String;
begin
Result := Self.Fone;
end;
procedure TAgenda.setFone(Fone: String);
begin
Self.Fone := Fone;
end;
end.
but it shows an error when I try to compile at Unit3: 'Undeclared identifier: 'IAgendas'
Why it shows me that error? I put the Unit at uses clause and it didn't recognize IAgendas.
Please help me with that, Thanks.
hmmmmm, doesn't give me an error
SHane
__________________________ __________ __________ __________ __________ _
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
end.
__________________________ __________ __________ __________ __________ _
unit Unit2;
interface
type
IAgendas = interface
['{2CFE9F89-A88D-4179-9429 -2340CC674 35B}']
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
end;
implementation
end.
__________________________ __________ __________ __________ __________ _
unit Unit3;
interface
uses Unit2;
type
TAgenda = class (TInterfacedObject, IAgendas)
public
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
private
Nome: String;
Fone: String;
end;
implementation
function TAgenda.getNome(): String;
begin
Result := Self.Nome;
end;
procedure TAgenda.setNome(Nome: String);
begin
Self.Nome := Nome;
end;
function TAgenda.getFone(): String;
begin
Result := Self.Fone;
end;
procedure TAgenda.setFone(Fone: String);
begin
Self.Fone := Fone;
end;
end.
end.
SHane
__________________________
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
end.
__________________________
unit Unit2;
interface
type
IAgendas = interface
['{2CFE9F89-A88D-4179-9429
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
end;
implementation
end.
__________________________
unit Unit3;
interface
uses Unit2;
type
TAgenda = class (TInterfacedObject, IAgendas)
public
function getNome(): String;
procedure setNome(Nome: String);
function getFone(): String;
procedure setFone(Fone: String);
private
Nome: String;
Fone: String;
end;
implementation
function TAgenda.getNome(): String;
begin
Result := Self.Nome;
end;
procedure TAgenda.setNome(Nome: String);
begin
Self.Nome := Nome;
end;
function TAgenda.getFone(): String;
begin
Result := Self.Fone;
end;
procedure TAgenda.setFone(Fone: String);
begin
Self.Fone := Fone;
end;
end.
end.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oh ****... I don't believe that the error was that... what attention lack.
Thanks man :)
Thanks man :)
<Smile>
I do that all the time - You can stare at the code for hours.....
SHane
I do that all the time - You can stare at the code for hours.....
SHane
ASKER
:)
ASKER