Skip to content

Instantly share code, notes, and snippets.

@patelmilanun
Created April 23, 2017 17:41
Show Gist options
  • Save patelmilanun/7851ab44731c30c516c4fa324430607e to your computer and use it in GitHub Desktop.
Save patelmilanun/7851ab44731c30c516c4fa324430607e to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class B;
class A {
private:
int x;
public:
A()
{
x=10;
}
friend int sub(A, B);
};
class B {
private:
int y;
public:
B()
{
y=2;
}
friend int sub(A , B);
};
int sub(A objectA, B objectB)
{
return (objectA.x - objectB.y);
}
int main()
{
A objectA;
B objectB;
cout<<"Substraction: "<< sub(objectA, objectB);
return 0;
}
================================output============================
Substraction: 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment