Guest User

Untitled

a guest
Jan 9th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Cl2;
  6.  
  7. class Cl1
  8.  
  9. {
  10.  
  11. int x;
  12.  
  13. public:
  14.  
  15. Cl1(int a) :x(a) {}
  16.  
  17. friend int sum(Cl1, Cl2);
  18. ~Cl1()
  19. {
  20. cout << "bebebbe";
  21. }
  22.  
  23. };
  24.  
  25. class Cl2
  26.  
  27. {
  28.  
  29. int y, z;
  30.  
  31. friend int sum(Cl1, Cl2);
  32.  
  33. public:
  34.  
  35. Cl2(int b, int c) :y(b), z(c) {}
  36. ~Cl2()
  37. {
  38. cout << "huiiiii" << endl;
  39. }
  40. };
  41.  
  42. int sum(Cl1 s, Cl2 f)
  43.  
  44. {
  45.  
  46. return s.x + f.y + f.z;
  47.  
  48. }
  49.  
  50. int main()
  51.  
  52. {
  53.  
  54. Cl1 m1(10);
  55.  
  56. Cl2 m2(20, 30);
  57.  
  58. cout << sum(m1, m2) << endl;//60
  59.  
  60. return 0;
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment