title: How to exit program execution after catching exception
body: <p>I was looking at the answer to this question:
  <a href="https://stackoverflow.com/questions/21781327/program-doesnt-stop-after-exception#_=_">Program doesn't stop after exception </a> <br></p>
  
  <p>The accepted writer proposes various techniques to exit a program upon catching an exception but also notes that <br></p>
  
  <blockquote>
    <p>exit and abort will NOT call the destructors of your local objects. </p>
  </blockquote>
  
  <p>So,if I use the first suggestion, which is to use the return keyword, how do I know what to return?</p>
  
  <p>For example, I am writing a <code>Stack&lt;T&gt;</code> class and have implemented the Pop function like this:</p>
  
  <pre><code>template &lt;typename T&gt;
  T Stack&lt;T&gt;::Pop() {
  
      try {
  
          return m_stack[--m_current_index];
  
      } catch(OutOfBoundsException &amp;obe) {
  
          std::cout &lt;&lt; "Stack Underflow" &lt;&lt; std::endl;
      }
  
  }
  </code></pre>
  
  <p>Here, <code>m_stack</code> is a custom array object of type <code>Array&lt;T&gt;</code> which throws an <code>OutOfBoundsException</code>.</p>
  
  <p><code>Stack&lt;T&gt;</code> follows a very basic implementation strategy where <code>m_current_index</code> represents the top of the Stack and the Stack size is fixed. So any push and pop operations simply increment or decrements <code>m_current_index</code>. </p>
  
  <p>Suppose that my stack is instantiated as <code>Stack&lt;int&gt; int_stack;</code> and I have popped off all values on my Stack. Now when I call the Pop function (<code>int_stack.Pop()</code>) I get the following output.</p>
  
  <blockquote>
    <p>Stack Underflow <br>
      5</p>
  </blockquote>
  
  <p>5 is the value that is at index 0 of the array.</p>
  
  <p>Now, if I use the return keyword to exit the program upon catching the exception, I can't really just return an integer because the user might think it's a valid value on the integer stack despite getting an exception.</p>