Original Post
I have the following code:
template <class T>
inline T &
LinkedList<T>::Peek()
{
if (this->pList==NULL)
{
T Dummy;
GlobalErrorWrap::HandleDefaultError(DEFERR_LINKEDLIST_INVALIDEMPTYOPERATION);
return Dummy;
}
return this->pList->Data;
}
I am throwing an exception in case of the specified error. However, on theory the HandleDefaultError does not necesseraly throws an exception and thus I cant rely on that the method wont continue. So I have to return from the method, but I have to return a value. I get a warnning on returning a local variable as a reference. Do you have a solution to this problem?