+ 2

Unexpected output

I was trying to throw a string inside a try-catch block. The code compiles, but there is a runtime error(maybe not an error) and an unexpected output. Please help explaining the output. Thanks. https://code.sololearn.com/c62NQglHAf2r/?ref=app

8th Feb 2018, 7:06 AM
Deepesh Choudhary
Deepesh Choudhary - avatar
2 Answers
+ 7
you can not use string, it must be a const char* Here is your example with the appropriate changes https://code.sololearn.com/cb1v1ytx0ZrV/?ref=app
8th Feb 2018, 7:12 AM
jay
jay - avatar
+ 3
@jay Thanks. I got my mistake, I was throwing a const char* but catching a string.
8th Feb 2018, 7:28 AM
Deepesh Choudhary
Deepesh Choudhary - avatar