A C language compiler is a rewriter. This means that the compiler decide the order of evaluation of the parts in a single line of source code.
cout<<a.remove()<<a.remove()<<a.remove()<<a.remove();
The compiler find it is more efficient to evaluate in reverse order;
You can check with this:
cout<<a.remove()+10<<a.remove()+20<<a.remove()+30<<a.remove()+40;