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
Зареєструйся Зараз
або Підпишись на майбутні тести