Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. class Drob
  5. {
  6. private:
  7. int a;
  8. int b;
  9. public:
  10. Drob()
  11. {
  12. a = b = 1;
  13. }
  14.  
  15. Drob(int a, int b)
  16. {
  17. this->a = a;
  18. this->b = b;
  19. }
  20.  
  21. int Get_a()
  22. {
  23. return a;
  24. }
  25. int Get_b()
  26. {
  27. return b;
  28. }
  29. void Set_a(int a)
  30. {
  31. this->a = a;
  32. }
  33. void Set_b(int b)
  34. {
  35. this->b = b;
  36. }
  37.  
  38. void Print()
  39. {
  40. std::cout << this->a << '/' << this->b << std::endl;
  41. }
  42.  
  43. Drob operator + (Drob other )
  44. {
  45. int tes = this->a * other.b;
  46. int ost = other.a * this->b;
  47. int asr = tes + ost;
  48. Drob rez(asr, ost);
  49. return rez;
  50. }
  51.  
  52. };
  53.  
  54. int main()
  55. {
  56. setlocale(0, "");
  57. system("color 2");
  58. Drob x(2, 4);
  59. Drob y(3, 5);
  60. Drob rez = x + y;
  61. std::cout << " " << std::endl;
  62. _getch();
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement