std::endl

Apr 7, 2014 at 2:25pm
Why this code report me this error??
Overload function with no contextual type information.

It isn't a function's overload...

prototype: ostream& endl (ostream& os);

 
(*endl)(cout);
Last edited on Apr 7, 2014 at 2:25pm
Apr 7, 2014 at 2:35pm
Actually endl is a function. the ostream operator << accepts a function of that type.

Read this:
http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/
Apr 7, 2014 at 2:37pm
Prototype:
1
2
template< class CHAR_TYPE, class TRAITS_TYPE >
std::basic_ostream< CHAR_TYPE, TRAITS_TYPE >& std::endl( std::basic_ostream< CHAR_TYPE, CHAR_TYPE >& ) ;


Either: std::endl( std::cout ) ; // types are deduced

Or: ( *std::endl< char, std::char_traits<char> > )(std::cout) ;
Topic archived. No new replies allowed.