Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Dropka{
- private:
- int a, b;
- public:
- Dropka(int _a = 1, int _b = 1) {
- a = _a;
- b = _b;
- }
- Dropka(const Dropka &d) {
- a = d.a;
- b = d.b;
- }
- Dropka& operator = (const Dropka &d) {
- a = d.a;
- b = d.b;
- return *this;
- }
- ~Dropka() {
- }
- Dropka& operator += (const Dropka &d) {
- int zi = b * d.b;
- a *= (zi / d.b);
- int tmp_a = d.a * (zi / b);
- a += tmp_a;
- b = zi;
- return *this;
- }
- Dropka& operator *= (const Dropka &d) {
- a *= d.a;
- b *= d.b;
- return *this;
- }
- Dropka& operator /= (const Dropka &d) {
- a *= d.b;
- b *= d.a;
- return *this;
- }
- int get_a() const {
- return a;
- }
- int get_b() const {
- return b;
- }
- };
- int main() {
- Dropka d1(2, 3);
- Dropka d2(3, 4);
- d1 /= d2;
- cout << d1.get_a() << " " << d1.get_b() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement