What will be displayed as a result of the program execution?
#include <iostream>

using namespace std;

struct B
  void f() { cout << "B"; }

struct C: B
  void f() { cout << "C"; }

int main()
  C c;

  B *b1 = &c;

  B b2 = c;
  return 0;
Method B::f() is not a virtual method, so when you access it through the pointer to the object of the base class, this method is called, not the overridden method of the child class.

Следи за CodeGalaxy

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

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