adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class BaseClass 
    {
        protected:
        int i;
        public:
        BaseClass(int x) 
        {
            i = x;
        }
        ~BaseClass() 
        {
        }
    };
    class DerivedClass: public BaseClass 
    {
        int j;
        public:
        DerivedClass(int x, int y): BaseClass(y)
        {
            j = x;
        }
        ~DerivedClass() 
        {
        }
        void show() 
        {
            cout << i << " " << j << endl;
        }
    };
    int main()
    {
        DerivedClass ob(3, 4);
        ob.show();
        return 0;
    }

a.

3 4

b.

4 3

c.

4

d.

3

Answer: (b).4 3

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?
Kinfu : June 26, 2023

Explain this question