I need to make a multiple inheritance in Delphi. Reading some articles, the most appropriate way is to do an interface.
How do I do this, knowing that we have the classes below as an example:
type
TPessoa = class
//atributos e métodos
end;
type
TPessoaFisica = class(TPessoa)
//atributos e métodos
end;
type
TPessoaJuridica = class(TPessoa)
//atributos e métodos
end;
I'm currently creating two variables and instantiating one, depending on the type of user selection. I wanted to span two in one and instantiate as needed.
var
CadPJ: TCadastroPJ;
CadPF: TCadastroPF;
begin
if rdTipoPessoa.ItemIndex = 0 then
begin
try
CadPF:= TCadastroPF.Create;
CadPF.LicencaIDCliente:= idCliente;
CadPF.NomePessoa:= edtNome.Text;
CadPF.gravarPF;
finally
CadPF.Free;
end;
end
else
begin
try
CadPJ:= TCadastroPJ.Create;
CadPJ.LicencaIDCliente:= idCliente;
CadPJ.NomeFantasia:= edtNomeFantasia.Text;
CadPJ.gravarPJ;
finally
CadPJ.Free;
end;
end;
end;