adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include<iostream>
    using namespace std;
    class X 
    {
        int m;
        public:
        X() : m(10)
        {                                                       
        }
        X(int mm): m(mm)
        {
        }
        int getm()
        {
            return m;
        }
    };
    class Y : public X 
    {
        int n;
        public:
        Y(int nn) : n(nn) {}                                                
        int getn() { return n; }
    };
    int main()
    {
        Y yobj( 100 );
        cout << yobj.getm() << " " << yobj.getn() << endl;
    }

a.

10 100

b.

100 10

c.

10 10

d.

100 100

Answer: (a).10 100

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?