Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<iostream>
  3. #include<iomanip>
  4. #include<string>
  5. using namespace std;
  6.  
  7. class Array
  8. {
  9.  
  10. friend ostream &operator<<(ostream&, const Array &);
  11. friend istream &operator>>(istream &, Array &);
  12.  
  13. public:
  14. Array();
  15. Array operator+(const Array&rhs)const;
  16.  
  17.  
  18. private:
  19. int a1[10];
  20. };
  21.  
  22.  
  23. Array Array::operator+(const Array&rhs) const
  24. {
  25. for (int i = 1; i <= 10; i++)
  26. {
  27.  
  28. }
  29. }
  30.  
  31. Array::Array()
  32. {
  33. for (int i = 1; i <= 10; i++)
  34. {
  35. a1[i] = 0;
  36. }
  37. }
  38.  
  39. ostream &operator<<(ostream &output, const Array &a)
  40. {
  41. for (int i = 1; i <= 10; i++)
  42. {
  43. output << a.a1[i] << ' ';
  44. }
  45. return output;
  46. }
  47.  
  48. istream &operator>>(istream &input, Array &a)
  49. {
  50. for (int i = 1; i <= 10; i++)
  51. {
  52. input >> a.a1[i];
  53. }
  54. return input;
  55. }
  56.  
  57.  
  58. int main()
  59. {
  60. Array a, b, sum, diff;
  61.  
  62. cout << "Enter data for first array: ";
  63. cin >> a;
  64. cout << "Enter data for second array: ";
  65. cin >> b;
  66. sum = a + b;
  67.  
  68. cout << "First array: " << a << endl << endl;
  69. cout << "Second array: " << b << endl << endl;
  70. cout << "Sum: " << sum << endl << endl;
  71.  
  72. system("PAUSE");
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement