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