当一个类在构造期间抛出异常时,分配的内存会发生什么,你将如何处理这样的事情.例如:
std::auto_ptr<ThirdPartyClass> au_tpc;
try
{
au_tpc.reset(new ThirdPartyClass());
}
catch(...)
{
// What happened to the memory allocated of
// sizeof(ThirdPartyClass) for the new instance?
}
Run Code Online (Sandbox Code Playgroud)