customize cout

前端 未结 6 960
你的背包
你的背包 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:37

    You could also override the operator. It will allow you to call another function or prefix/suffix anything that's going to leave the output buffer with whatever you wish: In your case, you'd have it output a specific string.

提交回复
热议问题