What type should I catch if I throw a string literal?

后端 未结 7 864
南笙
南笙 2020-12-05 18:11

I am writing a pretty simple application in C++ using g++ under Linux and I am trying to throw some raw strings as exceptions (yes, I know, its not a good practise).

7条回答
  •  借酒劲吻你
    2020-12-05 18:54

    The problem is that you're trying to catch something that is a const. The following will work:

    catch(const char* error) { cerr

提交回复
热议问题