Advertisement
Dijuna

const-verload

Apr 5th, 2020
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. //history = list<int>
  2.  
  3. int Attribute::getValue()
  4. {
  5.     if (changed > 0)
  6.     {
  7.         for (int idx = history.length() - changed; idx < history.length() - 1; ++idx)
  8.         {
  9.             value += history.at(idx);
  10.         }
  11.         changed = 0;
  12.     }
  13.     return value;
  14. }
  15.  
  16. int Attribute::getValue() const
  17. {
  18.     if (changed > 0)
  19.     {
  20.         int cvalue = value;
  21.         for (int idx = history.length() - changed; idx < history.length() - 1; ++idx)
  22.         {
  23.             cvalue += history.at(idx);
  24.         }
  25.         return cvalue;
  26.     }
  27.     return value;
  28. }
  29.  
  30. void Attribute::setValue(int value)
  31. {
  32.     history.append(value);
  33.     ++changed;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement