Advertisement
Guest User

.cpp

a guest
Oct 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include "klasy.h"
  2.  
  3. Punkt& Punkt::operator +=(Punkt& p)
  4. {
  5. x += p.x;
  6. y += p.y;
  7. return *this;
  8. }
  9.  
  10. Punkt& Punkt::operator =(Punkt& p)
  11. {
  12. x = p.x;
  13. y = p.y;
  14. return *this;
  15. }
  16.  
  17. bool Punkt::operator ==(Punkt& p)
  18. {
  19. if (x != p.x || y!=p.y)
  20. return false;
  21. else
  22. return true;
  23. }
  24.  
  25. Punkt Punkt::operator +(Punkt& p)
  26. {
  27. Punkt nowy(x + p.x, y + p.y);
  28. return nowy;
  29. }
  30.  
  31. std::ostream& operator<<(std::ostream& out, const Punkt& p)
  32. {
  33. out << "x: " << p.x << ", y: " << p.y;
  34. return out;
  35. }
  36.  
  37. std::ostream& operator<<(std::ostream& out, const Tablica& tab)
  38. {
  39. for (int i = 0; i < tab.dl; i++)
  40. {
  41. out << tab.w[i] << std::endl;
  42. }
  43. return out;
  44. }
  45.  
  46. Tablica& Tablica::operator=(const Tablica& tab)
  47. {
  48.  
  49. }
  50.  
  51. bool Tablica::operator==(const Tablica& tab) const
  52. {
  53. if (dl != tab.dl)
  54. return false;
  55. for (int i = 0; i < dl; i++)
  56. {
  57. Punkt temp1(w[i]);
  58. Punkt temp2(tab.w[i]);
  59. //if (!temp1.dodaj(temp2)) TODO
  60. return false;
  61. }
  62. return true;
  63. }
  64.  
  65. Tablica& Tablica::operator+=(const Tablica& tab)
  66. {
  67. for (int i = 0; i < tab.dl; i++)
  68. {
  69. w[i]+=(tab.w[i]); // lub w[i].operator+=(tab.w[i])
  70. }
  71. }
  72.  
  73. Punkt& Tablica::operator[](int i)
  74. {
  75. return w[i];
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement