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

class A
  A(){ cout << "A() "; }
  ~A(){ cout << "~A() "; }

class B : public A
  B(){ cout << "B() "; }
  ~B(){ cout << "~B() "; }

class C : public B
  C(){ cout << "C() "; }
  ~C(){ cout << "~C() "; }

int main()
  C* p = new C();
  delete p;
When creating an object of a child class, constructors are called in order from the base to the child. When the object is destroyed, the destructors are called in the opposite order - from the destructor of the child class to the base destructor.

Следи за CodeGalaxy

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

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