Why do i need to declare underflow_error
<p>In below code, i get error</p>

<p><code>Stack.cpp: In member function ‘T* Stack&lt;T&gt;::pop()’:
Stack.cpp:53: error: there are no arguments to ‘underflow_error’ that depend on a template parameter, so a declaration of ‘underflow_error’ must be available</code></p>

<p>What is the rationale behind declaring <code>class underflow_error;</code> ? </p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

template &lt;class T&gt;
class Stack
{
public:
    Stack(): head(NULL) {};
    ~Stack();

    void push(T *);
    T* pop();

protected:
    class Element {
    public:
            Element(Element * next_, T * data_):next(next_), data(data_) {}
            Element * getNext() const { return next; }
            T * value() const {return data;}
    private:
            Element * next;
            T * data;
    };

    Element * head;
};

template &lt;class T&gt;
Stack&lt;T&gt;::~Stack()
{
    while(head)
    {
            Element * next = head-&gt;getNext();
            delete head;
            head = next;
      }
 }

template &lt;class T&gt;
T * Stack&lt;T&gt;::pop()
{
    Element *popElement = head;
    T * retData;

    if(head == NULL)
            throw underflow_error("stack is empty");

    retData = head-&gt;value();
    head = head-&gt;getNext();

    delete popElement;
    return retData;
}
</code></pre>
