Skip to content

Instantly share code, notes, and snippets.

@viniciussanchez
Created June 4, 2021 18:32
Show Gist options
  • Save viniciussanchez/a5d64fe7c5b52c4d504ee284416f3ddc to your computer and use it in GitHub Desktop.
Save viniciussanchez/a5d64fe7c5b52c4d504ee284416f3ddc to your computer and use it in GitHub Desktop.
Class Operator Equal
type
TVenda = record
Valor: Currency;
QuantidadeItensVendidos: Integer;
class operator Equal(AVenda1, AVenda2: TVenda): Boolean;
end;
var
LVenda1, LVenda2: TVenda;
begin
LVenda1.Valor := 100;
LVenda1.QuantidadeItensVendidos := 10;
LVenda2.Valor := 100;
LVenda2.QuantidadeItensVendidos := 10;
if LVenda1 = LVenda2 then
ShowMessage('Igual')
else
ShowMessage('Diferente');
end;
{ TVenda }
class operator TVenda.Equal(AVenda1, AVenda2: TVenda): Boolean;
begin
Result := (AVenda1.Valor = AVenda2.Valor) and (AVenda1.QuantidadeItensVendidos = AVenda2.QuantidadeItensVendidos);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment