I suspect that you're tripping up the compiler. It doesn't expect you to play dirty tricks with e, so when it sees the line:
cout << e << endl;
It simply inserts the value 2 instead of looking for the actual value. You can verify (or disprove) this by looking at the disassembly of your program.