Shall I use cerr

后端 未结 4 1206
清歌不尽
清歌不尽 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:12

    One detail to keep in mind is that sending output directly to the terminal (with either cout or cerr), you do limit your ability to test for your error messages. It's always worth posing the question "How do I unit test this?".

提交回复
热议问题