You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.8 KiB

25 years ago
  1. // Abstract class of rational numbers.
  2. #ifndef _CL_RATIONAL_CLASS_H
  3. #define _CL_RATIONAL_CLASS_H
  4. #include "cl_number.h"
  5. #include "cl_real_class.h"
  6. class cl_RA : public cl_R {
  7. public:
  8. // Default constructor.
  9. cl_RA ();
  10. // Copy constructor.
  11. cl_RA (const cl_RA&);
  12. // Converters.
  13. // Assignment operators.
  14. cl_RA& operator= (const cl_RA&);
  15. // Constructors and assignment operators from C numeric types.
  16. cl_RA (const int); // |argument| must be < 2^29
  17. cl_RA (const unsigned int); // argument must be < 2^29
  18. cl_RA (const long);
  19. cl_RA (const unsigned long);
  20. cl_RA& operator= (const int); // |argument| must be < 2^29
  21. cl_RA& operator= (const unsigned int); // argument must be < 2^29
  22. cl_RA& operator= (const long);
  23. cl_RA& operator= (const unsigned long);
  24. // Other constructors.
  25. cl_RA (const char *);
  26. // Private constructor.
  27. cl_RA (cl_private_thing);
  28. cl_RA (struct cl_heap_ratio *);
  29. public: // Ability to place an object at a given address.
  30. void* operator new (size_t size) { return cl_malloc_hook(size); }
  31. void* operator new (size_t size, cl_RA* ptr) { (void)size; return ptr; }
  32. void operator delete (void* ptr) { cl_free_hook(ptr); }
  33. private:
  34. // Friend declarations. They are for the compiler. Just ignore them.
  35. };
  36. // Private constructors.
  37. inline cl_RA::cl_RA (cl_private_thing ptr) : cl_R (ptr) {}
  38. // The assignment operators:
  39. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_RA, cl_RA)
  40. // The default constructors.
  41. inline cl_RA::cl_RA ()
  42. : cl_R ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
  43. // The copy constructors.
  44. CL_DEFINE_COPY_CONSTRUCTOR2(cl_RA,cl_R)
  45. // Constructors and assignment operators from C numeric types.
  46. CL_DEFINE_INT_CONSTRUCTORS(cl_RA)
  47. CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_RA)
  48. CL_DEFINE_LONG_CONSTRUCTORS(cl_RA)
  49. CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_RA)
  50. #endif /* _CL_RATIONAL_CLASS_H */