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 character terminates all strings composed of character arrays? 1) 0 2) . 3) END

3 Answers  


difference between malloc and calloc

3 Answers   HCL, Wipro,


why you will give me a job in TCS.

7 Answers   TCS,


How do you convert strings to numbers in C?

0 Answers  


Is there any possibility to create customized header file with c programming language?

0 Answers  


What is a 'null pointer assignment' error?

0 Answers  


how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y

4 Answers   TCS,


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


Explain what is the most efficient way to store flag values?

0 Answers  


what are the files which are automatically opened when a c file is executed?

3 Answers  


The variables are int sum=10,SuM=20; these are same or different?

3 Answers  


Explain how do you convert strings to numbers in c?

0 Answers  


Categories