Hacker News new | past | comments | ask | show | jobs | submit login

If you call mmap/VirtualAlloc/open/fopen in your constructor and later it throws, you will have a resource leak, because the destructor won’t clean it up.



Again, you need to make the constructor exception safe, that's just like any other function. Just imagine the constructor and destructor bodies as one combined function. (Of course don't forget the method calls in between but those should preserve the class invariant).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: