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

Which are low level languages?

0 Answers  


Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.

7 Answers   Accenture, Gridco, IBM, Kevin IT, TCS, Vimukti Technologies,


What is define directive?

0 Answers  


what is the difference between call by value and call by reference?

5 Answers   Genpact, Global Logic, Infosys,


write a program to print %d ?

12 Answers  






program for swapping two strings by using pointers in c language

1 Answers  


What is the value of c?

0 Answers  


main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }

11 Answers   HCL, Vector, Vector India, Vector Solutions, Wipro,


Explain how can you restore a redirected standard stream?

0 Answers  


Can we change the value of constant variable in c?

0 Answers  


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

0 Answers  


When a c file is executed there are many files that are automatically opened what are they files?

0 Answers  


Categories