-
What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
int value1, value2, value3;
public:
int get()
{
value1 = 100;
value2 = 350;
value3 = 450;
}
friend float Average(Example obj);
};
float Average(Example obj)
{
return float(obj.value1 + obj.value2 + obj.value3) / 3;
}
int main()
{
Example object;
object.get();
cout << Average(object);
return 0;
}
-
- 100
- 200
- 300
- Compilation Error
- None of these
Correct Option: C
In this program, We are finding the Average value by declaring the function Average as a friend of class base.