0

what tells the computer that endl is a line return?

8th Jul 2016, 1:43 AM
Drew Graham
Drew Graham - avatar
4 odpowiedzi
+ 2
Ayush you are wrong. "endl" is *not* a keyword. "endl" is *not* part of C++ language itself (as every keyword is), it's part of the C++ *standard library* (header "iostream"). Therefore, the definition of "endl" is either in the header "iostream" or in a binary for that header.
8th Jul 2016, 10:32 AM
Stefan
Stefan - avatar
+ 1
zak, just because an element is in namespace "std" it doesn't mean it's not in the header "iostream". About namespace and files: You can have a namespace (therefore also namespace "std") in many places, i.e. files. The standard library is actually a good example. Every element from the standard library is in the namespace "std" but the standard library is split into many different header files, e.g. "iostream", "algorithm", "string", "cmath" etc. As the files from the standard library can be included separately, the namespace "std" has to be opened and closed in each of these files. You can also add your own functions to the standard library namespace "std". And as it happens, "endl" is in "std" which is also defined in "iostream".
9th Jul 2016, 1:48 AM
Stefan
Stefan - avatar
0
endl is not defined in the header! it is defined in the standard library in *std* you can verify that by removing the line * using namespace std* and write it that way *std::endl* but you have to write *std::cout* as well instead of *cout* alone because the program will not compile. you can try it in the playground
9th Jul 2016, 1:44 AM
zak
0
thanks @Stefan, I didn't know that
9th Jul 2016, 2:08 AM
zak