Advertisement
tei123

Operatory

Sep 15th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. class wektor
  8. {
  9. public:
  10. int x,y,z;
  11. wektor()
  12. {
  13. x=1;
  14. y=1;
  15. z=1;
  16. }
  17. };
  18. ostream&operator<<(ostream &str_wy, wektor we)
  19. {
  20. str_wy<<we.x<<we.y<<we.z<<endl;
  21. return str_wy;
  22. };
  23. istream &operator >> (istream & str_we, wektor&we)
  24. {
  25. str_we>>we.x>>we.y>>we.z;
  26. return str_we;
  27. };
  28. wektor operator+ (wektor g, wektor h)
  29. {
  30. wektor wynik;
  31. wynik.x=g.x+h.x;
  32. wynik.y=g.y+h.y;
  33. wynik.z=g.z+h.z;
  34. return wynik;
  35. };
  36. wektor operator+ (wektor g, int h)
  37. {
  38. wektor wynik;
  39. wynik.x=g.x+h;
  40. wynik.y=g.y+h;
  41. wynik.z=g.z+h;
  42. return wynik;
  43.  
  44. };
  45. wektor operator- (wektor g, int h)
  46. {
  47. wektor wynik;
  48. wynik.x=g.x-h;
  49. wynik.y=g.x-h;
  50. wynik.z=g.z-h;
  51. return wynik;
  52. };
  53.  
  54.  
  55. int main(int argc, char *argv[])
  56. {
  57.  
  58. wektor w,w1;
  59. cout<<w+w1;
  60. cout<<w;
  61. cout<<w+3;
  62. cout<<w-1;
  63. getch();
  64. system("PAUSE");
  65. return EXIT_SUCCESS;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement