Advertisement
Sanlover

Untitled

Oct 12th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #pragma once
  2.  
  3. using namespace std;
  4.  
  5. class LongLong
  6. {
  7. private:
  8. long* senior;
  9. unsigned long* junior;
  10. public:
  11. inline LongLong(__int64);
  12. inline LongLong(const LongLong&);
  13. inline ~LongLong();
  14. LongLong operator+(const LongLong&);
  15. LongLong& operator=(const LongLong& obj);
  16.  
  17. inline __int64 showInt64();
  18. };
  19.  
  20. LongLong::LongLong(__int64 number = 0)
  21. {
  22. senior = new long;
  23. *senior = number >> 32;
  24. junior = new unsigned long;
  25. *junior = number << 32 >> 32;
  26. }
  27. LongLong::LongLong(const LongLong& obj)
  28. {
  29. senior = new long; *senior = *obj.senior;
  30. junior = new unsigned long; *junior = *obj.junior;
  31. }
  32. LongLong::~LongLong()
  33. {
  34. delete senior;
  35. delete junior;
  36. }
  37. LongLong LongLong::operator+(const LongLong& obj)
  38. {
  39. LongLong a(*senior * pow(2, 32) + *junior + *obj.senior * pow(2, 32) + *obj.junior);
  40. return a;
  41. }
  42.  
  43. LongLong& LongLong::operator=(const LongLong& obj)
  44. {
  45. *junior = *obj.junior;
  46. *senior = *obj.senior;
  47. return *this;
  48. };
  49.  
  50. __int64 LongLong:: showInt64()
  51. {
  52. __int64 number = *senior * pow(2, 32) + *junior;
  53. return number;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement