How does “std::cout << std::endl;” compile?

后端 未结 4 2167
北荒
北荒 2020-12-10 12:36

Most IO stream manipulators are regular functions with the following signature:

std::ios_base& func( std::ios_base& str );

However

4条回答
  •  北海茫月
    2020-12-10 13:05

    You need to put << before the endl. It is a member of ofstream:

    namespace std {
    template  >
    class basic_ostream {
    public:
        basic_ostream& operator<<(
          basic_ostream& (*pf)(basic_ostream&));
        // ...
    };
    
    }
    

    endl works like a "/n" to skip the line, so you need a cout line to skip

提交回复
热议问题