【问题标题】:Is endl a method, and if it is can it take arguments?endl 是一种方法,如果是,它可以带参数吗?
【发布时间】:2012-08-11 06:05:24
【问题描述】:

当我遇到一些奇怪的事情时,我正在使用我的 code::blocks v10.05 编译器。它在我正要加回车的时候,提示endl,然后自动放这个:

    cout << "The age of " + age + " isn't that bad. Embrace it" << endl();

endl方法可以带参数吗?

【问题讨论】:

    标签: c++ methods


    【解决方案1】:

    endl是一个操纵函数:

    ostream& endl ( ostream& os );
    

    您可以将其连接到流中:

    cout << endl;
    

    或者将流作为参数传递给函数:

    endl(cout);
    

    【讨论】:

      【解决方案2】:

      我不知道,但显然我们可以将输出流传递给它 这是我在网上找到的:)

      http://www.cplusplus.com/reference/iostream/manipulators/endl/

      【讨论】:

      • 您可能要小心 cplusplus.com。当您想要查找库文档时,这是出了名的错误,因此是不可靠的来源。
      • @bitmask 感谢您的提醒,从现在开始我将交叉引用其他网站:)
      猜你喜欢
      • 1970-01-01
      • 2011-01-28
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多