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

Nguyễn Pháp

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

Tìm kiếm

Back
Top