Exception Handling with Stack in C++
<p>I have written a function for Stack where the function top() shows the top of the stack:</p>

<pre><code>class RuntimeException{
    private:
    string errorMsg;
    public:
    RuntimeException(const string&amp; err){errorMsg = err;}
    string getMessage() const {return errorMsg;}
    };

class StackEmpty : public RuntimeException{
public:
StackEmpty(const string&amp; err) : RuntimeException(err){}
};

template &lt;typename E &gt;
const E&amp; ArrayStack&lt;E&gt; ::top() const throw(StackEmpty)
{
    try{
        if(empty()) throw StackEmpty("Top of Empty Stack");
        return S[t];
        }
    catch(StackEmpty&amp; se){
        cout &lt;&lt; se.getMessage()&lt;&lt;"\n";
        }
    }


int main()
{
    ArrayStack &lt;int&gt; A;

    cout &lt;&lt; "######\n";
    cout &lt;&lt; A.top() &lt;&lt; "\n";
        cout &lt;&lt; "######\n";

    }
</code></pre>

<p>It shows below compilation warning:</p>

<pre><code>$ g++ -Wall Stack.cpp -o Stack
Stack.cpp: In member function `const E&amp; ArrayStack&lt;E&gt;::top() const [with E = int]':
Stack.cpp:91:   instantiated from here
Stack.cpp:61: warning: control reaches end of non-void function
</code></pre>

<p>The Output is:</p>

<pre><code>$ ./Stack
######
Top of Empty Stack
6649957
######
</code></pre>

<p>Can someone tell what the warning is about and how to resolve it ? Also what does the the number '6649957' in output signifies?</p>

<p>Thanks</p>
