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

Comments

Popular posts from this blog

How to configure Glowroot with Liferay

How to Get Back Asus Zenphone 5 from Soft Brick

How to Unlock Boot Loader of Htc Explorer