Skip to content

Instantly share code, notes, and snippets.

@patelmilanun
Created April 23, 2017 16:55
Show Gist options
  • Save patelmilanun/474a6ab6b42c4de0981fd3861de4b3da to your computer and use it in GitHub Desktop.
Save patelmilanun/474a6ab6b42c4de0981fd3861de4b3da to your computer and use it in GitHub Desktop.
#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