Correction: It WILL compile.
If it doesn't compile for you, then you must be getting errors somewhere, and I doubt it is with this piece of code (unless your compiler is out of date).
No. My definition of works is the program compiles and then runs with the expected results. I'm not sure if you consider both these definitions to mean the same thing, but that's what I mean by it works.