1
I need to make a multiple inheritance in Delphi. Reading some articles, the most appropriate way is to make 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 am currently creating two variables and instantiating one, according to the type of user selection. I wanted to encompass two in one and to 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;
Where is the multiple inheritance you want? If possible, create a simple UML diagram to show the inheritances.
– Vinícius Gobbo A. de Oliveira
It would be for the classes of PF and PJ, because in both already have the command to record person. I just wanted to instantiate an object that I can choose between PF and PJ. The way I’m doing, I need to create two variables
– André