Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class IntMod
- {
- private:
- int num;
- int mod;
- public:
- IntMod(int num = 0, int mod = 1) : num(num % mod), mod(mod) {}
- IntMod operator+(const IntMod& other);
- void get();
- };
- void IntMod::get()
- {
- cout << this->num << endl;
- }
- IntMod IntMod::operator+(const IntMod& other)
- {
- if (this->mod == other.mod)
- return IntMod((this->num + other.num) % this->mod, this->mod);
- }
- int main()
- {
- IntMod a, b(13,21), c(10,21),d(5,21);
- a = (b + c);
- a.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment