What will be the output of the following C++ code? [code] #include <iostream> using namespace std; class base {

What will be the output of the following C++ code?
Code:
    #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
 

Tìm kiếm

Back
Top