Sunday, January 26, 2014

C++ Program using Friend Function

with 0 Comment
C++ Program using Friend Function:

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class sample
{
int a;
int b;
public:
void setvalue()
{
a=25;
b=45;
}
friend float mean(sample s);
};
float mean(sample s)
{
return float(s.a+s.b)/2.0;
}
void main()
{
sample x;
clrscr();
x.setvalue();
cout<<"Mean value"<<mean(x)<<"\n";
getch();
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive