Skip to content

Instantly share code, notes, and snippets.

@viniciussanchez
Last active April 23, 2021 19:12
Show Gist options
  • Save viniciussanchez/8dc12b1744bda88daff6c0e57f39ae4d to your computer and use it in GitHub Desktop.
Save viniciussanchez/8dc12b1744bda88daff6c0e57f39ae4d to your computer and use it in GitHub Desktop.
Implementação do LSP
unit Solid.LSP;
interface
type
TClassePai = class
public
function GetNome: string;
end;
TCLasseDerivada = class(TClassePai)
end;
implementation
function TClassePai.GetNome: string;
begin
Result := 'Vinicius';
end;
end.
// LSP
procedure TForm1.MostrarNome;
var
LClasse: TClassePai;
begin
LClasse := TCLasseDerivada.Create;
try
ShowMessage(LClasse.GetNome); // Vinicius
finally
LClasse.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment