Is this code correct in terms of the memory management?

#include <exception>

struct A {
  void Foo() { throw std::exception(); }
};

void Test() {
  A *a = new A();
  a->Foo();
  delete a;
}
Explanation
No, because in the Test() function there is a leak of memory, allocated for a.

Следи за CodeGalaxy

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

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