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