When I am printing the stack twice, once before reversing the stack and once after it, why am I getting the output only once ?
s.push(1);
s.push(2);
s.push(3);
s.push(4);
s.push(5);
while(!s.empty()){
cout<<s.top()<<endl;
s.pop();
}
reverse(s);
while(!s.empty()){
cout<<s.top()<<endl;
s.pop();
}