Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.07 KB

exceptions-exceptions-in-constructors.md

File metadata and controls

18 lines (13 loc) · 1.07 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Exceptions: Exceptions in Constructors
Exceptions: Exceptions in Constructors
11/04/2016
constructors [MFC], exceptions
throwing exceptions [MFC], in constructors
exceptions [MFC], in constructors
a78eae5a-5821-4b27-9478-1436320ed1e1

Exceptions: Exceptions in Constructors

When throwing an exception in a constructor, clean up whatever objects and memory allocations you have made prior to throwing the exception, as explained in Exceptions: Throwing Exceptions from Your Own Functions.

When throwing an exception in a constructor, the memory for the object itself has already been allocated by the time the constructor is called. So, the compiler will automatically deallocate the memory occupied by the object after the exception is thrown.

For more information, see Exceptions: Freeing Objects in Exceptions.

See also

Exception Handling