ostream chaining, output order

前端 未结 5 1294
礼貌的吻别
礼貌的吻别 2020-11-30 11:38

I have a function that takes an ostream reference as an argument, writes some data to the stream, and then returns a reference to that same stream, like so:

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 12:09

    This would work, to combine print with << and control the order:

    print( std::cout << "Hello, world!" ) << std::endl;
    

    Or, if you want a function that's called with <<, see Joachim's answer.

提交回复
热议问题