Noncompliant compilers I guess. The const reference
has to work, otherwise most of the STL won't compile.
You can do whatever you want inside a catch block, however, the catch block is not part of the try block, so if you do something inside the catch block that throws, the catch block will not catch it. eg,
1 2 3 4 5
|
try {
throw 4;
} catch( int x ) {
throw 5;
}
| |
The catch block will catch the 4 but not the 5.
Your program is dying because p.guess() is throwing an H or an L and you have nothing to catch it. (An uncaught exception causes the program to abort, just as you are seeing).
(NB, if you have learned about const references, you should be catching by const reference, not by value. If you haven't learned about them, then ignore previous sentence).