Eclipse Luna C++ endl

190 Views Asked by At

I just started learning C++ and I noticed that when I do cout << "Some text" << endl; endl is not bold. I want to make sure that this is not a problem and it won't cause any future problems.

1

There are 1 best solutions below

2
On

Do not (<---- this intentionally bold!) use std::endl! Ever. It has no place in C++. It was a good idea but it is being abused. If you want a newline, use '\n'. If you want a flush, use a std::flush. Here is a more thorough explanation.

I don't know about Eclipse but I'd assume that it highlight keywords in bold: std::endl isn't a keyword. It is just a function (well, actually it is a function template but the details really don't matter) with a specific signature (std::ostream&(std::ostream&)) pointers to which are treated special when using it with an output operator on a std::ostream: the operator will just call the function with the stream as argument. These functions are called manipulators.