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

write the program for maximum of the following numbers? 122,198,290,71,143,325,98

5 Answers  


which is an algorithm for sorting in a growing Lexicographic order

0 Answers  


fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }

17 Answers   NDS,


Explain how do you determine whether to use a stream function or a low-level function?

0 Answers  


What is null character in c?

0 Answers  






how to devloped c lenguege?

4 Answers  


while running a program, i got the msg that press return key to exit.what that mean in C as there are no such options as far i know.

1 Answers   TCS,


What is 2c dna?

0 Answers  


Why cann't whole array can be passed to function as value.

1 Answers  


Explain how can I open a file so that other programs can update it at the same time?

0 Answers  


What is the memory allocated by the following definition ? int (*x)();

2 Answers   ADITI,


main() { int a[3][4] ={1,2,3,4,5,6,7,8,9,10,11,12} ; int i, j , k=99 ; for(i=0;i<3;i++) for(j=0;j<4;j++) if(a[i][j] < k) k = a[i][j]; printf("%d", k); }

4 Answers   Vector, Wipro, Zoho,


Categories