Created
April 23, 2017 16:55
-
-
Save patelmilanun/474a6ab6b42c4de0981fd3861de4b3da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Q; | |
class P { | |
private: | |
int x; | |
public: | |
P() | |
{ | |
x=10; | |
} | |
friend int add(P, Q); | |
}; | |
class Q { | |
private: | |
int y; | |
public: | |
Q() | |
{ | |
y=2; | |
} | |
friend int add(P , Q); | |
}; | |
int add(P objectA, Q objectB) | |
{ | |
return (objectA.x + objectB.y); | |
} | |
int main() | |
{ | |
P objectA; | |
Q objectB; | |
cout<<"Addition: "<< add(objectA, objectB); | |
return 0; | |
} | |
==========================output============================= | |
Addition: 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment