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.
Error: "Cannot convert int to &int"
dataType &top()
{
try
{
if (stackData.checkEmpty()== false)
{
throw stackData.size();
}
}
catch(...)
{
cout << "Stack size is zero. Can not retrieve top " << endl;
return stackData.size(); //***Where the problem is***
}
return stackData.back();
}
int size( ) const
{
return Size;
}