Advertisement
Guest User

przeciazenie

a guest
Nov 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class punkt
  6. {
  7.     public:
  8.     int x,y;
  9.     punkt(int wartosc_x, int wartosc_y):x(wartosc_x),y(wartosc_y)
  10.     {
  11.  
  12.     }
  13.     friend punkt operator+(const punkt& pkt1, const punkt& pkt2);
  14.     friend ostream& operator<<(ostream& out, punkt& pkt);
  15. };
  16. punkt operator+(const punkt& pkt1, const punkt& pkt2)
  17. {
  18.     return punkt(pkt1.x+pkt2.x, pkt1.y+pkt2.y);
  19. }
  20. ostream& operator<<(ostream& out, punkt& pkt)
  21. {
  22.     out<<"("<<pkt.x<<", "<<pkt.y<<")";
  23.     return out;
  24. }
  25.  
  26. int main()
  27. {
  28.     punkt poczatek(1,1), koniec(6,6);
  29.     punkt suma = poczatek + koniec;
  30.     cout<< suma<<endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement