Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- class Drob
- {
- private:
- int a;
- int b;
- public:
- Drob()
- {
- a = b = 1;
- }
- Drob(int a, int b)
- {
- this->a = a;
- this->b = b;
- }
- int Get_a()
- {
- return a;
- }
- int Get_b()
- {
- return b;
- }
- void Set_a(int a)
- {
- this->a = a;
- }
- void Set_b(int b)
- {
- this->b = b;
- }
- void Print()
- {
- std::cout << this->a << '/' << this->b << std::endl;
- }
- Drob operator + (Drob other )
- {
- int tes = this->a * other.b;
- int ost = other.a * this->b;
- int asr = tes + ost;
- Drob rez(asr, ost);
- return rez;
- }
- };
- int main()
- {
- setlocale(0, "");
- system("color 2");
- Drob x(2, 4);
- Drob y(3, 5);
- Drob rez = x + y;
- std::cout << " " << std::endl;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement