Im trying to reverse a stack, by simply putting it into another stack from the top, so that it could be reversed. Here is the code:
#include <bits/stdc++.h>
using namespace std;
stack<char> Reverse(stack<char> &st) {
stack<char> sk;
if (st.empty()) return sk;
sk.push(st.top());
st.pop();
Reverse(st);
}
int main() {
stack<char> st;
st.push('a');
st.push('b');
st.push('c');
st.push('d');
stack<char> sk = Reverse(st);
}
Please help me find the error.