adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base1
    {
        protected:
        int SampleDataOne;
        public:
        Base1()
        {
            SampleDataOne = 100;
        }
        ~Base1()
        {
        }
        int SampleFunctOne()
        {
            return SampleDataOne;
        }
    };
    class Base2
    {
        protected:
        int SampleDataTwo;
        public:
        Base2()
        {
            SampleDataTwo = 200;
        }
        ~Base2()
        {
        }
        int SampleFunctTwo()
        {
            return SampleDataTwo;
        }
    };
    class Derived1 : public Base1, public Base2
    {
        int MyData;
        public:
        Derived1() 
        {
            MyData = 300;
        }
        ~Derived1()
        {
        }    
        int MyFunct()
        {
            return (MyData + SampleDataOne + SampleDataTwo);
        }
    };
    int main()
    {
        Base1 SampleObjOne;
        Base2 SampleObjTwo;
        Derived1 SampleObjThree;
        cout << SampleObjThree.Base1 :: SampleFunctOne() << endl;
        cout << SampleObjThree.Base2 :: SampleFunctTwo() << endl;
        return 0;
    }

a.

100

b.

200

c.

Both 100 & 200

d.

None of the mentioned

Answer: (c).Both 100 & 200

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?