Why can't throw/catch a const string
Hi friends,
I found the following codes and the catch
block couldn't get the string correctly. Could you please help to see it. Thanks.
Code:
#include <iostream>
using namespace std;
void test(void)
{
try
{
cout<<"This is try block!\n";
throw "String";
// char str[]="String";
// throw str;
cout<<"This is hidden block!\n";
}
catch(char *str)
{
cout<<"This is catch block!"<<endl;
cout<<"The caught string is "<<str<<endl;
}
}
int main(void)
{
cout<<"Start"<<endl;
test();
cout<<"End"<<endl;
}