C++ Fixing a programming excercise
<p>My teacher asked the class to fix the error in this program. Actually it seems to be a crappy program; I just typed it exactly how it is in the sheet, and got this error:</p>

<p>Well Now I have just change some things, but get this exception at run time: Microsoft C++ exception: [rethrow] at memory location 0x00000000..</p>

<p>The code is now like so: (The variable an class names are now in spanish, sorry for the inconviniences)</p>

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

class EPilaVacia : public exception{
public:
    const char* what() const throw(){
        return "Error: Pila Vacía";
    }
};

template &lt;class T, int max=100&gt;
class Pila{
private:
    stack&lt;T*&gt; *pila;
    int cont;
public:

    Pila() : cont(0){
        pila=new stack&lt;T*&gt;();
    }
    virtual void apilar( T* pt){
        if(cont&lt;max){
            pila-&gt;push(pt); //respuesta 2
        }
    }
    virtual void apilar(T t){
        if(cont&lt;max){
            pila-&gt;push(&amp;t); //respuesta 3
        }
    }
    T tope() const throw (EPilaVacia){
        if(cont&gt;0){
            pila-&gt;top(); //respuesta 4
        }else{
            throw ; //respuesta 5
        }
    }
    T&amp; desapilar() throw (EPilaVacia){
        if(cont&gt;0){
            pila-&gt;pop(); //respuesta 6
        }else{
            throw ; //respuesta 7
        }
    }
    int size() const{
        return pila-&gt;size();
    }
};

class Figura{
public:

    virtual void print(){
        cout&lt;&lt; "FIGURA" &lt;&lt;endl;
    }
};

class Circulo : public Figura{
public:
    void print(){
        cout&lt;&lt;"CIRCULO"&lt;&lt;endl;
    }
};

class Triangulo : public Figura{
public:
    void print(){
        cout&lt;&lt;"TRIANGULO"&lt;&lt;endl;
    }
};

int main(){
    Pila&lt;Figura*&gt; *pfiguras= new Pila&lt;Figura*&gt;();
    pfiguras-&gt;apilar(new Circulo());
    pfiguras-&gt;apilar(new Triangulo());
    Pila&lt;Figura*&gt; pfiguras2(*pfiguras);
    pfiguras-&gt;tope()-&gt;print();
    pfiguras-&gt;desapilar();
    pfiguras-&gt;tope()-&gt;print();
    pfiguras-&gt;desapilar();

    pfiguras2.tope()-&gt;print();
    system("Pause");
    return 0;
}
</code></pre>
