C++ tips: Why the pop method of STL stack does not return a value

Or why they don’t combine the functionality of pop/top method into one function? We know that the pop method pops the top element of the stack, change the stack’s internal state but returns nothing; and the top method returns a reference to the top element on the stack, but does not change the stack’s internal…

0

C++ tips: why you should not leak exception from a destructor

One of the reasons: we know the destructor of an auto object can be called in two situations:  1. When the object is out of scope normally.  2. During the stack unwind when handling an exception. For situation 2, if the destructor throws another exceptions when it is handling the first exception, C++ will call…

0

Structured Exception Handling (SEH) and C++ exception handling

C++ exception handling builds on top of the OS SEH support. If you are writing C++ code, it is recommended you use C++ exception handing since SEH does not know how to handle C++ objects properly. For example, for below code: #include “stdafx.h”   class MyClass { public:         ~MyClass()         {                printf(“Myclass dtor\r\n”);…

0