函数返回的是一个局部变量的引用,局部变量会在结束时销毁,因此引用可能出错
template <class T>
const T& QStack<T>::topValue(QStack<T>* s) const {
T temp = s->pop();
s->push(temp);
return temp; // 这个地方warning的原因是:返回了局部变量的引用,局部变量会在结束时销毁
}
template <class T>
const T& QStack<T>::topValue(){
return topValue(this);
}