Advertisement
TechOPGOHIL

Untitled

Dec 3rd, 2023
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. //friend function
  2.  
  3. #include<iostream.h>
  4. #include<conio.h>
  5. class kishan; //below class kishan is not ritched or not compilar confused who is kishan thats why we declare here.
  6. class omdevsinh
  7. {
  8.     private : // if you not write this it will be fine no change in output
  9.     int a; //this is money pocket assumed
  10.     public:
  11.     omdevsinh()
  12.     {
  13.         //this is default consturactor
  14.         a=5600;
  15.     }
  16.     friend void zeeshan(omdevsinh,kishan); //zeeshan is friend of kishan and omdevsinh.
  17.  
  18.  
  19. };
  20. class kishan
  21. {
  22.     int b;
  23.     public:
  24.     kishan()
  25.     {
  26.         b=4400;
  27.     }
  28.     friend void zeeshan(omdevsinh,kishan); //zeeshan is friend of kishan and omdevsinh.
  29.  
  30. };
  31. void zeeshan(omdevsinh o,kishan k) //zeeshan is friend of kishan and omdevsinh.
  32. {
  33.     cout<<"Thief takes Money From Omdevsinh and Kishan "<<o.a+k.b<<" Rs";
  34. }
  35.  
  36. void main()
  37. {
  38.     clrscr();
  39.      omdevsinh o;
  40.      kishan k;
  41.      zeeshan(o,k);
  42.      getch();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement