title: Using top with empty stack
body: <p>So i have a custom stack class and a top function. Im checking if the top is empty but am having some trouble returning a value without error.</p>
  
  <p>Error: "Cannot convert int to &amp;int"</p>
  
  <pre><code>    dataType &amp;top()
  {
      try
      {               
          if (stackData.checkEmpty()== false)
          {
              throw stackData.size();
          }
      }
      catch(...)
      {
          cout &lt;&lt; "Stack size is zero. Can not retrieve top " &lt;&lt; endl;
          return stackData.size(); //***Where the problem is***
      }
  
      return stackData.back();
  }
  
  int size( ) const
  {
      return Size;
  }
  </code></pre>