What will be printed out as a result of the following code execution?
#include <iostream>
using namespace std;

class Base {
    public:
        void method(){};
};

class Child : public Base {
    public:
        void method() { cout << "Child"; };
};

int main()
{
    Base* base = new Child();
    base->method();   
    return 0; 
}
Explanation
The call is performed based on the type of the pointer, and since the method is not virtual in the base class, the method of the derived class is NOT called.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes