Can you guess what the following program writes to standard output when run?
#include <iostream>
#include <stack>
typedef std::stack<char> stack;
inline stack & push(stack & st, char c)
{
st.push(c);
return st;
}
inline char pop(stack & st)
{
char const c = st.top();
st.pop();
return c;
}
int main(int, char * [])
{
stack st;
push(push(push(st, 'c'), 'b'), 'a');
std::cout << pop(st) << pop(st) << pop(st) << std::endl;
return 0;
}
Note that you may find it enlightening to try this program with different compilers, i.e. with GCC, MSVC, and ICC.