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 |
code for quick sort?
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.'%')
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.
which one is highest Priority in c? a)=,b)+,c)++,d)==
Can you apply link and association interchangeably?
The difference between printf and fprintf is ?
Explain how can I convert a string to a number?
write c program without semicolon
11 Answers MindTech, TCS, Wipro,
what does ‘segmentation violation’ mean?
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”.
Explain the use of fflush() function?
What is return type in c?