What is the output of this program?
#include <iostream>
using namespace std;
class base
{
int val1, val2;
public:
int get()
{
val1 = 100;
val2 = 300;
}
friend float mean(base ob);
};
float mean(base ob)
{
return float(ob.val1 + ob.val2) / 2;
}
int main()
{
base obj;
obj.get();
cout << mean(obj);
return 0;
}
a) 200
b) 150
c) 100
d) 300
Submitted by: Administratora) 200
Submitted by:
Submitted by:
Read Online C++ Friend Job Interview Questions And Answers
Top C++ Friend Questions
☺ | List the characteristics of friend functions? |
☺ | Explain the characteristics of friend functions? |
☺ | What is a friend function? |
☺ | What are friend classes? |
☺ | Explain advantages of using friend classes? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |
☺ | C++ Template Interview Questions. |