无法打印来自异常的消息

时间:2017-12-10 12:52:48

标签: c++ exception

我试图在跟踪How come I don't can't print out error from my throw exception?之后抛出异常,但它不会打印消息。它只打印terminate called after throwing an instance of 'char const*'而不是test

以下是简短的代码段

try{
        if(A.size().lines != B.size().lines || A.size().cols != B.size().lines){
            throw std::runtime_error("test");
        }
    }
    catch (std::exception const& exc)
    {
        std::cerr << exc.what() << "\n";
    }

0 个答案:

没有答案