Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Array.h"
- class Decimal :
- public Array
- {
- private:
- public:
- Decimal();
- Decimal(const Decimal &other);
- public:
- void read();
- void write();
- void sum(Array *sec, Array *result) override; // Сумма
- void sub(Array *sec, Array *result) override; // Разность
- void prod(Array *sec, Array *result) override; // Произведение
- void div(Array *sec, Array *result) override; // Частное
- Decimal operator = (const Decimal & other)
- {
- this->_array = other._array;
- this->size = other.size;
- }
- Decimal operator + (const Decimal & other)
- {
- Decimal Result;
- unsigned int res_size = this->size + 1;
- for (unsigned int i = 0; i < res_size-1; i++)
- {
- if (this->_array[i] + other._array[i] >= 10)
- {
- Result._array[i] = (this->_array[i] + other._array[i]) % 10;
- Result._array[i + 1] += 1;
- }
- else
- {
- Result._array[i] = (this->_array[i] + other._array[i]);
- }
- }
- return Result;
- }
- public:
- ~Decimal();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement