⟩ What is output of this program? #include <iostream> using namespace std; class sample { private int a, b; public void test() { a = 100; b = 200; } friend int compute(sample e1); }; int compute(sample e1) { return int(e1.a + e1.b) - 5; } int main() { sample e; e.test(); cout << compute(e); return 0; } a) 100 b) 200 c) 300 d) 295
d) 295
Explanation:
In this program, we are finding a value from the given function by using the friend for compute function.
Output:
$ g++ friend4.cpp
$ a.out
295