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

code for quick sort?

0 Answers  


if a five digit number is input through the keyboard, write a program to calculate the sum of its digits. (hint:-use the modulus operator.'%')

23 Answers  


write a program in c language that uses function to locate and return the smallest and largest integers in an array,number and their position in the array. it should also find and return the range of the numbers , that is , the difference between the largest number and the smallest.

1 Answers  


which one is highest Priority in c? a)=,b)+,c)++,d)==

4 Answers  


Can you apply link and association interchangeably?

0 Answers   InterGraph,






The difference between printf and fprintf is ?

0 Answers   Baan Infotech,


Explain how can I convert a string to a number?

0 Answers  


write c program without semicolon

11 Answers   MindTech, TCS, Wipro,


what does ‘segmentation violation’ mean?

1 Answers  


whenever a question is posted in a particular category in allinterview.com, Is there any facility to receive an indication mail. For eg: I need to receive an indication email, whenever a question is posted under the category “C Langauage”.

1 Answers  


Explain the use of fflush() function?

0 Answers  


What is return type in c?

0 Answers  


Categories