title: C++ Throwing Exception If Popping Empty Queue
body: <p>I'm writing an implementation of a priority queue using linked list nodes in C++. </p>
  
  <p>I am new to the language and would really appreciate it if someone could help me figure out how to throw an exception when the pop() function is called on an empty queue.  </p>
  
  <p>I have tried using the try and catch exception handling but my code keeps getting a "segmenation fault error"</p>
  
  <p>My priority queue is implemented correctly.. push(), isEmpty(), size(), clear() work. pop() also functions but I want to throw an exception if the user makes an illegal call. </p>
  
  <pre><code>try {
      if(isEmpty()) {
          throw -1;
      }
  }
  catch(int n) {
      cout &lt;&lt; "ERROR" &lt;&lt; n &lt;&lt; ": LIST IS EMPTY" &lt;&lt; endl;
  }
  </code></pre>