Friend Function Using C++ Programming
#include<iostream.h> #include<conio.h> class Ashish { int a,b; public: void input() { cout<<"Enter two values:"; cin>>a>>b; } friend int info(Ashish ob); }; int info(Ashish ob) { return int(ob.a+ob.b)/2; } void main() { clrscr(); Ashish m; m.input(); cout<<"\n value is : "<<info(m); getch(); } Output: Enter two values: 10, 20 Mean Value is: 15