Tuesday, October 23, 2012

Question 13: Predict the output.
    class Base
    {
    public:
        void display()
        {
            std::cout<<"\nBase class display function.";
        }
    };

    class Derive : public Base
    {
    public:
        void display()
        {
            std::cout<<"\nDerive class display function.";
        }
    };

    int main()
    {
        Base* obj = new Derive();
        obj->display();
    }


    Options:
    (a) Base class display function.
    (b) Derive class display function.
    (c) Compile Time error: error C2248: 'Base:: display’ : cannot access private member declared in class 'Base'
    (d) Runtime Error


    Answer: a

No comments:

Post a Comment