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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты