简体   繁体   中英

Eclipse Luna C++ endl

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM