Advertisement
vguk

Untitled

May 19th, 2020
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. enum class var_types
  4. {
  5. int_type, float_type, none
  6. };
  7.  
  8. class variable
  9. {
  10. private:
  11. union
  12. {
  13. int int_value;
  14. float float_value;
  15. } value;
  16. var_types type;
  17. public:
  18. variable();
  19. variable(int value);
  20. variable(float value);
  21. variable(const variable& other);
  22. variable& operator=(const variable& other);
  23. variable operator*(const variable& other);
  24. variable operator+(const variable& other);
  25. variable operator-(const variable& other);
  26. variable operator/(const variable& other);
  27. variable operator%(const variable& other);
  28. bool operator==(const variable& other);
  29. bool operator>(const variable& other);
  30. bool operator!=(const variable& other);
  31. bool operator<(const variable& other);
  32. bool operator>=(const variable& other);
  33. bool operator<=(const variable& other);
  34. operator int ();
  35.  
  36. void reinit(int val);
  37. void reinit(float val);
  38. void reinit(const variable& other);
  39. friend std::ostream& operator<<(std::ostream& out, const variable& val);
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement