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

class Base
{
   public:
      virtual void f() { std::cout << "Base"; }
};

class Child : public Base
{
   public:
      int f() { std::cout << "Child"; }
};

int main()
{
   Child c;
   c.f();
}
Explanation
Since the f() function is declared as virtual in the Base class, the compiler will not allow to change its return type in the derived Child class.

Следи за CodeGalaxy

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

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