Shall I use cerr

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

    Yes, because while by default they both go to the terminal, you could change where their output is directed, and you may wish cerr to go to a log file while cout continues to just go to stdout.

    Essentially it gives you more control over where different output goes if you want it now or in the future.

提交回复
热议问题