5 ms·
In C++, if the construction fails (with an exception), no other member function - not even the destructor - gets called and the resource is not acquired.
by potiuper 4y ago
In C++, if the construction fails (with an exception), no other member function - not even the destructor - gets called and the resource is not acquired.
- opportune 4y agoThis is one reason many people think exceptions in C++ are harmful, they cause unclear implicit behavior. Much better to handle a failure explicitly outside the constructor
- benibela 4y agoThis is one reason I use Pascal If the constructor throws an exception, the destructor is called immediately.