Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //friend function
- #include<iostream.h>
- #include<conio.h>
- class kishan; //below class kishan is not ritched or not compilar confused who is kishan thats why we declare here.
- class omdevsinh
- {
- private : // if you not write this it will be fine no change in output
- int a; //this is money pocket assumed
- public:
- omdevsinh()
- {
- //this is default consturactor
- a=5600;
- }
- friend void zeeshan(omdevsinh,kishan); //zeeshan is friend of kishan and omdevsinh.
- };
- class kishan
- {
- int b;
- public:
- kishan()
- {
- b=4400;
- }
- friend void zeeshan(omdevsinh,kishan); //zeeshan is friend of kishan and omdevsinh.
- };
- void zeeshan(omdevsinh o,kishan k) //zeeshan is friend of kishan and omdevsinh.
- {
- cout<<"Thief takes Money From Omdevsinh and Kishan "<<o.a+k.b<<" Rs";
- }
- void main()
- {
- clrscr();
- omdevsinh o;
- kishan k;
- zeeshan(o,k);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement