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

How do we declare variables in c?

0 Answers  


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


how to determine the complexity of an algorithm as log(n)

1 Answers   Google,


What's the difference between DELETE TABLE and TRUNCATE TABLE commands?

2 Answers   CTC,


How will you divide two numbers in a MACRO?

0 Answers   Apps Associates,


How can my program discover the complete pathname to the executable from which it was invoked?

0 Answers  


What is main void in c?

1 Answers  


How do I get an accurate error status return from system on ms-dos?

0 Answers  


write a proram to reverse the string using switch case?

0 Answers   Syntel,


1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?

3 Answers   Qualcomm,


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

0 Answers  


What is meant by high-order and low-order bytes?

0 Answers  


Categories