Is the following code correct in terms of freeing up resources?
#include <exception>

struct A {
  ~A() { throw std::exception(); }
};
Explanation
No, because an exception thrown from the destructor can lead to an incomplete release of resources occupied by the object (in this case, the memory, and if A was inherited from another class, there would be a resources leak, since its destructor would not be called).

Следи за CodeGalaxy

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

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