Advertisement
Guest User

Untitled

a guest
May 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. TMyInteger = record
  2. private
  3. fValue: Integer;
  4. fIsChanged: Boolean;
  5. public
  6. // Присвоение Integer
  7. class operator Implicit(const A: Integer): TMyInteger;
  8. // Чтение значения. Не помню, можно ли так же через неявную конвертацию или нет
  9. property Value: Integer read fValue;
  10. property IsChanged: Boolean read fIsChanged;
  11. // Тут еще надо переопределить конструктор New, который будет заполнять поля нулями
  12. // А можно сделать fIsChanged: string; тогда поле будет пустым при первом обращении)
  13. end;
  14.  
  15. ....
  16.  
  17. class operator TMyInteger.Implicit(const A: Integer): TMyInteger;
  18. begin
  19. Result.fValue := A;
  20. Result.fIsChanged := True;
  21. end;
  22.  
  23. I := TMyInteger.New;
  24. I := 45;
  25. Assert(I.IsChanged, 'I is changed');
  26.  
  27. myInt: Integer;
  28. myVar: Integer;
  29.  
  30. if (myInt==myVar) then
  31. он не изменился
  32. else
  33. он изменился сохраняем новое значение
  34. myVar := myInt;
  35. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement