0

How do you use std::logic_error to pass a string exception?

my code is something like this try{ //some code throw std::logic error("A string") }catch( std::logic_error string_caught) { cout << string_caught << endl; } I try doing it this way but i get errors. i need someone to provide a working example so that i can understand it better.

30th Nov 2016, 12:57 AM
J.C Vega
J.C Vega - avatar
2 ответов
+ 1
Try to use: cout << string_caught.what() << endl;
30th Nov 2016, 7:52 AM
AtoMX
AtoMX - avatar
+ 1
Thanks! That worked :)
4th Dec 2016, 9:54 PM
J.C Vega
J.C Vega - avatar