Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #ifndef CALCULATOR_H
  2. #define CALCULATOR_H
  3.  
  4.  
  5. class calculator {
  6.  
  7. private:
  8. double accumulator = 0;
  9.  
  10. public:
  11.  
  12. void clear() {
  13. accumulator = 0;
  14. }
  15.  
  16. double add(int num) {
  17. accumulator += num;
  18. }
  19.  
  20. double sub(int num) {
  21. accumulator -= num;
  22. }
  23.  
  24. double mul(int num) {
  25. accumulator *= num;
  26. }
  27.  
  28. double div(int num) {
  29. accumulator /= num;
  30. }
  31. double get() {
  32. return accumulator;
  33. }
  34. void store() {
  35. double &accumaltor = accumulator;
  36. }
  37. double * recall() {
  38. return &accumulator;
  39. }
  40. };
  41.  
  42.  
  43. #endif //CALCULATOR_CALCULATOR_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement