Shall I use cerr

后端 未结 4 1169
清歌不尽
清歌不尽 2021-01-04 10:30

Is it in good style do use cerr in situation described below?

try
    {
    cout << a + b;
    }
    catch(const IntException& e)
    {
        c         


        
4条回答
  •  清酒与你
    2021-01-04 11:31

    stderr is the traditional stream to send error messages (so that the OS/shell/whatever can capture error messages separately from "normal" output), so yes, use std::cerr!

    I make no comment as to whether catching an exception simply to print it out is any better than simply letting the exception propagating out of your application...

提交回复
热议问题