-
What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
private:
int p, q;
public:
void test()
{
p = 150;
q = 250;
}
friend int Calculate(Example Exmp1);
};
int Calculate(Example Exmp1)
{
return int(Exmp1.p + Exmp1.q) - 5;
}
int main()
{
Example obj;
obj.test();
cout << Calculate(obj);
return 0;
}
-
- 250
- 295
- 150
- 395
- None of these
Correct Option: D
In this program, we are finding a value from the given function by using the friend for Calculate function.