I have seen questions similar to this one but none of them helped me due to the fact that I could not find one that was using a template. For a homework assignment, I have to code a stack that can be used with any type of variable, so I have decided to use a template. This prevents me from initializing variables, my code gives me a warning for the function pop() can anyone give me suggestions on how to remove such warning?
my function pop():
template<typename T>
T stack<T>::pop(){
T result;
if(!empty()){
result = tos->data;
Node<T> *tmp = tos;
tos = tos->next;
delete tmp;
}else{
std::cerr<<"ERROR empty stack"<<std::endl;
}
return result;
}