main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include<iostream.h> #include<conio.h> class second; class first { int s1; public: void enter() { cout<<"Enter the S1 : "; cin>>s1; } friend int fun(first,second); }; class second { int s2; public: void get() { cout<<"Enter the S2:"; cin>>s2; } friend int fun(first, second); }; int fun(first f1,second f2) { return f1.s1+f2.s2; } int main() { clrscr(); first ob1; second ob2; ob1.enter(); ob2.get(); cout<<"The Sum of two object is : "<<fun(ob1,ob2); getch(); return 0; } |