Last active
April 23, 2021 19:12
-
-
Save viniciussanchez/8dc12b1744bda88daff6c0e57f39ae4d to your computer and use it in GitHub Desktop.
Implementação do LSP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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