Haval1

B

May 4th, 2019
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. //Second question in OOP Labs ( B )
  2. #include"iostream"
  3. #include"string"
  4. using namespace std;
  5. class secondClass;
  6. class firstClass
  7. {
  8. private:
  9.     int a[4];
  10. public:
  11.     void set()
  12.     {
  13.         int i;
  14.         for (i = 0; i < 4; i++)
  15.         {
  16.             cout << "Enter Data : ";
  17.             cin >> a[i];
  18.         }
  19.     }
  20.     friend void check(firstClass, secondClass);
  21. };
  22. class secondClass
  23. {
  24. private:
  25.     int x;
  26. public:
  27.     void set()
  28.     {
  29.         cout << "Enter Number : "; cin >> x;
  30.     }
  31.     friend void check(firstClass, secondClass);
  32. };
  33. void  check(firstClass f, secondClass s)
  34. {
  35.     if (s.x == 1)
  36.         f.a[4] += 10;
  37.     else if (s.x == 0)
  38.         f.a[4] -= 10;
  39. }
  40. int main()
  41. {
  42.     firstClass f;
  43.     secondClass s;
  44.     f.set();
  45.     s.set();
  46.     check(f, s);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment