customize cout

前端 未结 6 965
你的背包
你的背包 2021-02-06 00:22

How can I derive a class from cout so that, for example, writing to it

new_cout << \"message\";

would be equivalent to

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 00:54

    You have to override operator<<(), but you even don't have to subclass std::cout. You may also create a new object or use existing objects like that.

提交回复
热议问题