Example of friendly function in c++
Answers were Sorted based on User's Feedback
Answer / harry0009
#include<iostream.h>
class sample
{
int a,b;
public:
void setvalue()
{
a = 25;
b = 45;
}
friend float mean(sample s);
};
float mean(sample s)
{
return(float(s.a+& b)/20);
}
void main()
{
sample ;
x.setvalue
cout<<"mean value"<<mean(x);
getch();
}
Is This Answer Correct ? | 11 Yes | 4 No |
What is the most efficient way to count the number of bits which are set in an integer?
Explain b+ tree?
write function to reverse char array ... without using second array
What are reserved words with a programming language?
What is meant by operator precedence?
wt is diference between int and int pointer as same as float and float pointer and char and char pointer
What is calloc malloc realloc in c?
How can I list all of the predefined identifiers?
What are the functions to open and close the file in c language?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is ctrl c called?
What are the storage classes in C?