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).
The type of a string literal is char const *
. There's a (deprecated) conversion to char *
provided for backward compatibility with existing code (but you still have to treat it as const
-- any attempt at modification gives UB).
As such, code like this should work:
#include
using namespace std;
int main()
{
try
{
throw "not implemented";
}
catch(char const *error)
{
cerr<<"Error: "<