adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    struct A 
    {
        private:
        int i, j, k;
        public:
        int f();
        void g();
    };
    int A :: f() 
    {
        return i + j + k;
    }
    void A :: g() 
    {
        i = j = k = 0;
    }
    class B 
    {
        int i, j, k;
        public:
        int f();
        void g();
    };
    int B :: f() 
    {
        return i + j + k; 
    }
    void B :: g() 
    {
        i = j = k = 0;
    }
    int main() 
    {
        A a;
        B b;
        a.f(); 
        a.g();
        b.f(); 
        b.g();
        cout << "Identical results would be produced";
    }

a.

50

b.

Identical results would be produced

c.

Error

d.

Runtime error

Answer: (b).Identical results would be produced

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?