| ghantauke (4) | |||
I receive the "Should not output this" output even when exception occurs in the cin >> foo statement. Why doesn't return(0) work as I'm assuming it to work and what's the right way of doing it? | |||
|
|
|||
| Felicia123 (176) | |||||
insert
inside your
| |||||
|
|
|||||
| Peter87 (3917) | |
| If line 4 throws an exception line 12 should never run. Are you sure it throws an exception? | |
|
Last edited on
|
|
| deckeresq (2) | |
|
Peter87 is right, it looks like an exception isn't ever being thrown. For debugging purposes, try adding in a cout << foo; right after you try to read foo in. This will let you know if an error is occurring or if your program is reading in something that you aren't expecting/don't want it to. In what context are you putting cin in a try block, by the way? That might help us figure out a better way to set this up. | |
|
Last edited on
|
|
| SamuelAdams (321) | |||
Reference : http://www.cplusplus.com/doc/tutorial/exceptions/ | |||
|
Last edited on
|
|||
| Cubbi (1927) | |||
|
@ghantauke If you were meaning to catch exeptions thrown by cin >> foo, you need to enable them first, try
| |||
|
|
|||