Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3.  
  4. using namespace std;
  5.  
  6. class cos
  7. {
  8.     int a, b;
  9.     public:
  10.         cos(int l1=0, int l2=0):a(l1),b(l2){}
  11.         //cos(cos & kopia){a=kopia.a; b=kopia.b;    }
  12.         friend ostream & operator << (ostream &, cos &);
  13.         cos & operator ++() {a++; b++; return *this;    }
  14.         friend cos operator +(const cos &, const cos &);
  15. };
  16.  
  17. cos l1(3,4);
  18. cos l2(4,5);
  19. cos l3;
  20.  
  21. int main()
  22. {
  23.     //l2.wypisz();
  24.     cout<<l2;
  25.     ++l2;
  26.     cout<<l2;
  27.     l3=l1+l2;
  28.     cout<<l3;
  29.     getch();
  30.     return 0;
  31. }
  32.  
  33. cos operator +(const cos & l1, const cos & l2)
  34. {
  35.     return cos(l1.a + l2.a, l1.b+l2.b);
  36. }
  37.  
  38. ostream & operator <<(ostream & ekran, cos & l)
  39. {
  40.     ekran<<l.a<<" "<<l.b<<endl;
  41.     return ekran;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement