Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

Write a program to find mean value of 2 numbers using friend function


#include<iostream.h>
#include<conio.h>
class base
{
int val1,val2;
public:
void getdata()
{
cout<<"Enter value 1: ";
cin>>val1;
cout<<"Enter value 2: ";
cin>>val2;
}
friend float mean (base obj);
};
float mean(base obj)
{
return float(obj.val1 + obj.val2)/2;
}
void main()
{
clrscr();
base obj;
obj.getdata();
cout<<"Mean value is: "<<mean(obj);
getch();
}

 Output


Previous
Next Post »