2019.11.05 C++コンパイルwarning:Reference to stack memory associated with local variable'xxx'returned


関数はローカル変数の参照を返します.ローカル変数は終了時に破棄されるため、参照エラーが発生する可能性があります.
template 
const T& QStack::topValue(QStack* s) const {
    T temp = s->pop();
    s->push(temp);
    return temp;    //     warning    :          ,           
}
template 
const T& QStack::topValue(){
    return topValue(this);
}