try
{
if (isfull()==1)
throw "full stack";
else
a[top++] = x;
}
catch (const char *s)
{
cout<<s;
}
Run Code Online (Sandbox Code Playgroud)
我们为什么要在catch块中使用const?如果我不使用它,我会收到此错误:
terminate called after throwing an instance of 'char const*'
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)