C ++ STL containers stack usage details

Today algorithm solving a problem, use the C ++ STL in the stack, the stack when found as long as space-time, when then execute the query to stack or pop the top element, the program will interrupt debug:

Such as the following:

 

 When combined, it becomes if (S.top () || S.empty ()) {..} program may be interrupted ahead of the end;

Of course, so write if (S.empty () || S.top ()) {..} may be, but the proposal is still not error-prone

Guess you like

Origin www.cnblogs.com/debug-the-heart/p/12528827.html