Example of friendly function in c++

Answers were Sorted based on User's Feedback



Example of friendly function in c++..

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

Example of friendly function in c++..

Answer / guest

friend

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Interview Questions

What is the most efficient way to count the number of bits which are set in an integer?

0 Answers  


Explain b+ tree?

0 Answers  


write function to reverse char array ... without using second array

3 Answers  


What are reserved words with a programming language?

0 Answers  


What is meant by operator precedence?

0 Answers  






wt is diference between int and int pointer as same as float and float pointer and char and char pointer

8 Answers   CTS, Infosys,


What is calloc malloc realloc in c?

0 Answers  


How can I list all of the predefined identifiers?

0 Answers  


What are the functions to open and close the file in c language?

0 Answers  


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

1 Answers   CMS,


What is ctrl c called?

0 Answers  


What are the storage classes in C?

0 Answers  


Categories