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

后端 未结 7 860
南笙
南笙 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:43

    The exact type of a string literal is an array of const characters (const char [15] for your example, since the NUL terminator is included). The array decays to const char* when thrown, which is independent of the length.

提交回复
热议问题