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 |
How do we declare variables in c?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
how to determine the complexity of an algorithm as log(n)
What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
How will you divide two numbers in a MACRO?
How can my program discover the complete pathname to the executable from which it was invoked?
What is main void in c?
How do I get an accurate error status return from system on ms-dos?
write a proram to reverse the string using switch case?
1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What is meant by high-order and low-order bytes?