Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class second;
- class first{
- int x;
- public:
- void getvalue(){
- cout<<"Enter number ";
- cin>>x;
- }
- friend void sum(first,second);
- };
- class second{
- int y;
- public:
- void getvalue(){
- cout<<"Enter number ";
- cin>>y;
- }
- friend void sum(first,second);
- };
- void sum(first a , second b){
- cout<<"\nsum is "<<a.x+b.y;
- }
- int main()
- {
- first a;
- second b;
- a.getvalue();
- b.getvalue();
- sum(a,b);
- return 0;
- }
- /*
- Output
- Enter number 1
- Enter number 2
- sum is 3
- */
Advertisement
Add Comment
Please, Sign In to add comment