It is fairly straight forward:
- You read an argument and decide if it is a value or a variable. If it is, you push the argument on the stack. If it isn't it is an operator.
- If you have an operator, you create a tree consisting of the operator as the root and as many arguments of the stack as its children. You push the tree on the stack.
- When you want to print the infix notation you do an in-order walk of the top of the stack (the original post-fix notation is just a post-order walk of the same tree).
To deal with this in C++ I create a base class (Expression) with derived class representing the different kinds of nodes (Value, Variable, and BinaryOperation) and maintain a std::stack>. Coding this out is mainly a typing exercise.